diff --git a/backoffice/backoffice/workflows/api/views.py b/backoffice/backoffice/workflows/api/views.py index e2554df7..03ae0804 100644 --- a/backoffice/backoffice/workflows/api/views.py +++ b/backoffice/backoffice/workflows/api/views.py @@ -198,7 +198,9 @@ def resolve(self, request, pk=None): logger.info("Resolving data: %s", request.data) serializer = AuthorResolutionSerializer(data=request.data) if serializer.is_valid(raise_exception=True): - extra_data = {"create_ticket": serializer.validated_data["create_ticket"]} + extra_data = {"user_id": str(request.user.id)} + print("extra_data") + print(extra_data) logger.info( "Trigger Airflow DAG: %s for %s", ResolutionDags[serializer.validated_data["value"]], diff --git a/backoffice/backoffice/workflows/migrations/0010_remove_decision_user_id_decision_user.py b/backoffice/backoffice/workflows/migrations/0010_remove_decision_user_id_decision_user.py new file mode 100644 index 00000000..92216fe5 --- /dev/null +++ b/backoffice/backoffice/workflows/migrations/0010_remove_decision_user_id_decision_user.py @@ -0,0 +1,31 @@ +# Generated by Django 4.2.6 on 2024-08-14 09:10 + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ("workflows", "0009_decision"), + ] + + operations = [ + migrations.RemoveField( + model_name="decision", + name="user_id", + ), + migrations.AddField( + model_name="decision", + name="user", + field=models.ForeignKey( + db_column="email", + default=1, + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + to_field="email", + ), + preserve_default=False, + ), + ] diff --git a/backoffice/backoffice/workflows/models.py b/backoffice/backoffice/workflows/models.py index bf9866e8..c30652eb 100644 --- a/backoffice/backoffice/workflows/models.py +++ b/backoffice/backoffice/workflows/models.py @@ -46,7 +46,9 @@ class WorkflowTicket(models.Model): class Decision(models.Model): - user_id = models.ForeignKey(User, on_delete=models.CASCADE) + user = models.ForeignKey( + User, to_field="email", db_column="email", on_delete=models.CASCADE + ) workflow_id = models.ForeignKey(Workflow, on_delete=models.CASCADE) action = models.CharField(max_length=30, choices=ResolutionDags.choices)