Generate engagement tasks automatically and repair missing tasks
This commit is contained in:
@@ -270,6 +270,31 @@ def generate_tasks_for_subscription(db: Session, *, subscription: ClientServiceS
|
||||
|
||||
|
||||
|
||||
def generate_tasks_for_subscription_if_ready(
|
||||
db: Session,
|
||||
*,
|
||||
subscription: ClientServiceSubscription,
|
||||
user_id: int,
|
||||
) -> int:
|
||||
"""Generate task instances when the engagement is allowed to execute.
|
||||
|
||||
Non-assurance engagements are ready immediately. Assurance engagements keep
|
||||
the existing AQMM acceptance gate: no task is generated until acceptance is
|
||||
approved. The underlying generator remains idempotent and will not duplicate
|
||||
an existing subscription/template/year task instance.
|
||||
"""
|
||||
if (
|
||||
quality_required_for_engagement(subscription.engagement_type)
|
||||
and getattr(subscription, "quality_acceptance_status", None) != QUALITY_APPROVED
|
||||
):
|
||||
return 0
|
||||
return generate_tasks_for_subscription(
|
||||
db,
|
||||
subscription=subscription,
|
||||
user_id=user_id,
|
||||
)
|
||||
|
||||
|
||||
|
||||
def _latest_task_documents(db: Session, task_id: int) -> list[EngagementDocument]:
|
||||
return db.execute(
|
||||
|
||||
Reference in New Issue
Block a user