From 3075950dadd47db6a485cadf5bae67f4b0e6cf57 Mon Sep 17 00:00:00 2001 From: DonHaul Date: Wed, 14 Aug 2024 15:55:29 +0200 Subject: [PATCH] draft decisions done --- backoffice/backoffice/workflows/api/views.py | 9 ++++----- .../dags/author/author_create/author_create_approved.py | 8 ++++---- workflows/dags/author/author_create/shared_tasks.py | 4 ---- 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/backoffice/backoffice/workflows/api/views.py b/backoffice/backoffice/workflows/api/views.py index 890693a8..87f1c8dd 100644 --- a/backoffice/backoffice/workflows/api/views.py +++ b/backoffice/backoffice/workflows/api/views.py @@ -21,7 +21,6 @@ from rest_framework.decorators import action from rest_framework.response import Response -from backoffice.users.models import User from backoffice.utils.pagination import OSStandardResultsSetPagination from backoffice.workflows import airflow_utils from backoffice.workflows.api.serializers import ( @@ -118,18 +117,18 @@ def retrieve(self, request, *args, **kwargs): def create(self, request, *args, **kwargs): workflow_id = request.data.get("workflow_id") action = request.data.get("action") - email = request.data.get("email") - if not all([workflow_id, action, email]): + if not all([workflow_id, action]): return Response( - {"error": "workflow_id, action and email are required."}, + {"error": "workflow_id and action are required."}, status=status.HTTP_400_BAD_REQUEST, ) try: workflow = Workflow.objects.get(id=workflow_id) + decision = Decision.objects.create( - workflow_id=workflow, user=User.object.get(email=email), action=action + workflow_id=workflow, user=request.user, action=action ) serializer = DecisionSerializer(decision) return Response(serializer.data, status=status.HTTP_201_CREATED) diff --git a/workflows/dags/author/author_create/author_create_approved.py b/workflows/dags/author/author_create/author_create_approved.py index 95c2ccb7..c05163ad 100644 --- a/workflows/dags/author/author_create/author_create_approved.py +++ b/workflows/dags/author/author_create/author_create_approved.py @@ -168,11 +168,11 @@ def set_author_create_workflow_status_to_error(**context: dict) -> None: set_workflow_status_to_error_task = set_author_create_workflow_status_to_error() combine_ticket_and_no_ticket_task = empty_task() - combine_ticket_and_no_ticket_task = empty_task() + create_decision_on_curation_choice_task = create_decision_on_curation_choice() - complete_task = [ - create_decision_on_curation_choice() >> set_workflow_status_to_completed_task - ] + complete_task = ( + create_decision_on_curation_choice_task >> set_workflow_status_to_completed_task + ) # task dependencies ticket_branch = create_author_create_curation_ticket_task diff --git a/workflows/dags/author/author_create/shared_tasks.py b/workflows/dags/author/author_create/shared_tasks.py index 55bbda11..544cca60 100644 --- a/workflows/dags/author/author_create/shared_tasks.py +++ b/workflows/dags/author/author_create/shared_tasks.py @@ -4,11 +4,7 @@ @task() def create_decision_on_curation_choice(**context): - print("create_decision_on_curation_choice") - print(context["params"]) - data = { - "email": context["params"]["data"]["email"], "action": context["params"]["data"]["value"], "workflow_id": context["params"]["workflow_id"], }