Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
author submissions: add author accept curate action
Browse files Browse the repository at this point in the history
  • Loading branch information
DonHaul committed Aug 12, 2024
1 parent a202b4d commit 720429e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
29 changes: 27 additions & 2 deletions backoffice/backoffice/workflows/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ class AuthorWorkflowViewSet(viewsets.ViewSet):
serializer_class = WorkflowAuthorSerializer

@extend_schema(
summary="Create a New Author",
description="Creates a new author, launches the required airflow dags.",
summary="Create/Update an Author",
description="Creates/Updates an author, launches the required airflow dags.",
request=serializer_class,
)
def create(self, request):
Expand All @@ -127,6 +127,31 @@ def create(self, request):
workflow.data,
)

@extend_schema(
summary="Updates an Author",
description="Updates an author, launches the required airflow dag.",
request=serializer_class,
)
def update(self, request, pk=None):
logger.info("Creating workflow with data: %s", request.data)
serializer = self.serializer_class(data=request.data)
if serializer.is_valid(raise_exception=True):
workflow = Workflow.objects.create(
data=serializer.validated_data["data"],
workflow_type=WorkflowType.AUTHOR_UPDATE,
)

logger.info(
"Trigger Airflow DAG: %s for %s",
WORKFLOW_DAGS[workflow.workflow_type].initialize,
workflow.id,
)
return airflow_utils.trigger_airflow_dag(
WORKFLOW_DAGS[workflow.workflow_type].initialize,
str(workflow.id),
workflow.data,
)

@extend_schema(
summary="Partially Updates Author",
description="Updates specific fields of the author.",
Expand Down
1 change: 1 addition & 0 deletions backoffice/backoffice/workflows/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class WorkflowType(models.TextChoices):

class ResolutionDags(models.TextChoices):
accept = "accept", "author_create_approved_dag"
accept_curate = "accept_curate", "author_create_approved_dag"
reject = "reject", "author_create_rejected_dag"


Expand Down

0 comments on commit 720429e

Please sign in to comment.