diff --git a/backoffice/backoffice/workflows/migrations/0010_alter_decision_workflow_and_more.py b/backoffice/backoffice/workflows/migrations/0010_alter_decision_workflow_and_more.py new file mode 100644 index 00000000..a9cefea0 --- /dev/null +++ b/backoffice/backoffice/workflows/migrations/0010_alter_decision_workflow_and_more.py @@ -0,0 +1,31 @@ +# Generated by Django 4.2.6 on 2024-08-23 13:02 + +import django.db.models.deletion +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + ("workflows", "0009_decision"), + ] + + operations = [ + migrations.AlterField( + model_name="decision", + name="workflow", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="decisions", + to="workflows.workflow", + ), + ), + migrations.AlterField( + model_name="workflowticket", + name="workflow_id", + field=models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="tickets", + to="workflows.workflow", + ), + ), + ] diff --git a/backoffice/backoffice/workflows/models.py b/backoffice/backoffice/workflows/models.py index 1ec12b45..d4fb3704 100644 --- a/backoffice/backoffice/workflows/models.py +++ b/backoffice/backoffice/workflows/models.py @@ -51,11 +51,12 @@ class Decision(models.Model): user = models.ForeignKey( User, to_field="email", - related_name="tickets", db_column="email", on_delete=models.CASCADE, ) - workflow = models.ForeignKey(Workflow, on_delete=models.CASCADE) + workflow = models.ForeignKey( + Workflow, related_name="decisions", on_delete=models.CASCADE + ) action = models.CharField(max_length=30, choices=DECISION_CHOICES) _created_at = models.DateTimeField(auto_now_add=True) diff --git a/backoffice/backoffice/workflows/tests/test_views.py b/backoffice/backoffice/workflows/tests/test_views.py index e61a7747..d9395e95 100644 --- a/backoffice/backoffice/workflows/tests/test_views.py +++ b/backoffice/backoffice/workflows/tests/test_views.py @@ -108,7 +108,7 @@ def test_decisions(self): workflow_data = WorkflowSerializer(self.workflow).data assert "decisions" in workflow_data assert "action" in workflow_data["decisions"][0] - assert "email" in workflow_data["decisions"][0] + assert "user" in workflow_data["decisions"][0] @pytest.mark.vcr() def test_delete(self):