Skip to content

Commit

Permalink
Merge pull request #1290 from Amsterdam/fix/131678-complete-sub-wf
Browse files Browse the repository at this point in the history
Make sure sub wf gets completed
  • Loading branch information
NvdLaan authored Dec 11, 2024
2 parents 3ea1261 + 0e311d2 commit 659c35a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
8 changes: 8 additions & 0 deletions app/apps/workflow/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ def force_update_workflows(modeladmin, request, queryset):
task_update_workflow.delay(workflow.id)


@admin.action(description="Complete subworkflows if there are no open tasks")
def complete_sub_workflow(modeladmin, request, queryset):
for workflow in queryset.all():
wf = workflow.get_or_restore_workflow_state()
workflow.complete_sub_workflow(wf)


@admin.action(description="Remove workflows for closed cases")
def remove_workflows_for_closed_cases(modeladmin, request, queryset):
queryset.filter(
Expand Down Expand Up @@ -91,6 +98,7 @@ class CaseWorkflowAdmin(admin.ModelAdmin):
migrate_worflows_to_latest,
force_update_workflows,
remove_workflows_for_closed_cases,
complete_sub_workflow,
)

def issues(self, obj):
Expand Down
11 changes: 10 additions & 1 deletion app/apps/workflow/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,16 @@ def complete_workflow(self):
def update_tasks(self, wf):
self.set_absolete_tasks_to_completed(wf)
self.create_user_tasks(wf)
self.complete_sub_workflow(wf)

# The sub_workflow.bpmn has multiple flows inside, so spiff does not know when the workflow is completed.
def complete_sub_workflow(self, wf):
if (
self.workflow_type == self.WORKFLOW_TYPE_SUB
and len(wf.get_ready_user_tasks()) == 0
):
self.completed = True
self.save()

@staticmethod
def get_task_by_task_id(id):
Expand Down Expand Up @@ -558,7 +568,6 @@ def save_workflow_state(self, wf):
self.data.update(wf.last_task.data)

completed = False

if wf.is_completed() and not self.completed:
completed = True
self.completed = True
Expand Down
1 change: 1 addition & 0 deletions app/config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,7 @@ def filter_traces(envelope):
LOCAL_DEVELOPMENT_AUTHENTICATION = (
os.getenv("LOCAL_DEVELOPMENT_AUTHENTICATION", False) == "True"
)

DATA_UPLOAD_MAX_MEMORY_SIZE = 5242880
DATA_UPLOAD_MAX_NUMBER_FIELDS = 6000

Expand Down

0 comments on commit 659c35a

Please sign in to comment.