From 152533cb4810aefbccf1fbd40248a71d44ce85af Mon Sep 17 00:00:00 2001 From: DonHaul Date: Fri, 23 Aug 2024 15:05:02 +0200 Subject: [PATCH] backoffice: added decision connecion in serializer * ref: cern-sis/issues-inspire/issues/518 --- .../0010_alter_decision_workflow_and_more.py | 31 +++++++++++++++++++ backoffice/backoffice/workflows/models.py | 5 +-- .../backoffice/workflows/tests/test_views.py | 2 +- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 backoffice/backoffice/workflows/migrations/0010_alter_decision_workflow_and_more.py 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):