diff --git a/tasks/migrations/0012_taskworkflow_assign_summary_task.py b/tasks/migrations/0012_taskworkflow_assign_summary_task.py index 38f0dda86..26e22ed3b 100644 --- a/tasks/migrations/0012_taskworkflow_assign_summary_task.py +++ b/tasks/migrations/0012_taskworkflow_assign_summary_task.py @@ -12,7 +12,7 @@ def assign_new_summary_task_on_workflow(apps, schema_editor): title="Workflow summarising task", description="Workflow summarising task.", ) - TaskWorkflow.save() + task_workflow.save() class Migration(migrations.Migration): diff --git a/tasks/models/workflow.py b/tasks/models/workflow.py index 35f149252..26a00c931 100644 --- a/tasks/models/workflow.py +++ b/tasks/models/workflow.py @@ -91,13 +91,13 @@ def get_task_templates(self) -> models.QuerySet: ) @atomic - def create_task_workflow(self) -> "TaskWorkflow": + def create_task_workflow(self, title: str, description: str) -> "TaskWorkflow": """Create a workflow and it subtasks, using values from this template workflow and its task templates.""" + summary_task = Task.objects.create(title=title, description=description) task_workflow = TaskWorkflow.objects.create( - title=self.title, - description=self.description, + summary_task=summary_task, creator_template=self, ) diff --git a/tasks/tests/test_workflow_models.py b/tasks/tests/test_workflow_models.py index 270e7b055..93cda5eed 100644 --- a/tasks/tests/test_workflow_models.py +++ b/tasks/tests/test_workflow_models.py @@ -13,8 +13,13 @@ def test_create_task_workflow_from_task_workflow_template( ): """Test creation of TaskWorkflow instances from TaskWorkflowTemplates using its `create_task_workflow()` method.""" + title = "Workflow title" + description = "Workflow description" task_workflow = ( - task_workflow_template_three_task_template_items.create_task_workflow() + task_workflow_template_three_task_template_items.create_task_workflow( + title=title, + description=description, + ) ) # Test that workflow values are valid. @@ -22,11 +27,8 @@ def test_create_task_workflow_from_task_workflow_template( task_workflow.creator_template == task_workflow_template_three_task_template_items ) - assert task_workflow.title == task_workflow_template_three_task_template_items.title - assert ( - task_workflow.description - == task_workflow_template_three_task_template_items.description - ) + assert task_workflow.summary_task.title == title + assert task_workflow.summary_task.description == description assert task_workflow.get_items().count() == 3 # Validate that item positions are equivalent.