diff --git a/backoffice/backoffice/workflows/__init__.py b/backoffice/backoffice/authors/__init__.py similarity index 100% rename from backoffice/backoffice/workflows/__init__.py rename to backoffice/backoffice/authors/__init__.py diff --git a/backoffice/backoffice/workflows/admin.py b/backoffice/backoffice/authors/admin.py similarity index 88% rename from backoffice/backoffice/workflows/admin.py rename to backoffice/backoffice/authors/admin.py index d870fd858d..f256b82e0e 100644 --- a/backoffice/backoffice/workflows/admin.py +++ b/backoffice/backoffice/authors/admin.py @@ -3,10 +3,14 @@ from django_json_widget.widgets import JSONEditorWidget from backoffice.management.permissions import IsAdminOrCuratorUser -from backoffice.workflows.models import Decision, Workflow, WorkflowTicket +from backoffice.authors.models import ( + AuthorDecision, + AuthorWorkflow, + AuthorWorkflowTicket, +) -class WorkflowsAdminSite(admin.AdminSite): +class AuthorWorkflowsAdminSite(admin.AdminSite): """ Custom admin site for managing workflows. @@ -63,8 +67,8 @@ def has_delete_permission(self, request, obj=None): } -class WorkflowsDecisionsInline(admin.StackedInline): - model = Decision +class AuthorWorkflowsDecisionsInline(admin.StackedInline): + model = AuthorDecision extra = 0 can_delete = False show_change_link = True @@ -78,8 +82,8 @@ def action_value(self, obj): return obj.action -class WorkflowTicketsInline(admin.StackedInline): - model = WorkflowTicket +class AuthorWorkflowTicketsInline(admin.StackedInline): + model = AuthorWorkflowTicket extra = 0 can_delete = False show_change_link = True @@ -89,7 +93,7 @@ def has_change_permission(self, request, obj=None): return False -@admin.register(Workflow) +@admin.register(AuthorWorkflow) class WorkflowAdmin(BaseModelAdmin): """ Admin class for Workflow model. Define get, update and delete permissions. @@ -101,24 +105,20 @@ class WorkflowAdmin(BaseModelAdmin): "id", "workflow_type", "status", - "core", - "is_update", "_created_at", "_updated_at", ) list_filter = [ "workflow_type", "status", - "core", - "is_update", "_created_at", "_updated_at", ] - inlines = [WorkflowsDecisionsInline, WorkflowTicketsInline] + inlines = [AuthorWorkflowsDecisionsInline, AuthorWorkflowTicketsInline] -@admin.register(Decision) +@admin.register(AuthorDecision) class DecisionAdmin(BaseModelAdmin): """ Admin class for Decision model. Define get, update and delete permissions. @@ -137,7 +137,7 @@ def action_value(self, obj): return obj.action -@admin.register(WorkflowTicket) +@admin.register(AuthorWorkflowTicket) class WorkflowTicketAdmin(BaseModelAdmin): """ Admin class for WorkflowTicket model. Define get, update and delete permissions. diff --git a/backoffice/backoffice/workflows/airflow_utils.py b/backoffice/backoffice/authors/airflow_utils.py similarity index 99% rename from backoffice/backoffice/workflows/airflow_utils.py rename to backoffice/backoffice/authors/airflow_utils.py index 3683f65112..80a6404ab3 100644 --- a/backoffice/backoffice/workflows/airflow_utils.py +++ b/backoffice/backoffice/authors/airflow_utils.py @@ -6,7 +6,7 @@ from requests.exceptions import RequestException from rest_framework import status -from backoffice.workflows.constants import WORKFLOW_DAGS +from backoffice.authors.constants import WORKFLOW_DAGS AIRFLOW_BASE_URL = environ.get("AIRFLOW_BASE_URL") diff --git a/backoffice/backoffice/workflows/api/serializers.py b/backoffice/backoffice/authors/api/serializers.py similarity index 60% rename from backoffice/backoffice/workflows/api/serializers.py rename to backoffice/backoffice/authors/api/serializers.py index ba7f3fd6a7..9018932a17 100644 --- a/backoffice/backoffice/workflows/api/serializers.py +++ b/backoffice/backoffice/authors/api/serializers.py @@ -4,19 +4,22 @@ from drf_spectacular.utils import OpenApiExample, extend_schema_serializer from inspire_schemas.utils import get_validation_errors from rest_framework import serializers - -from backoffice.workflows.api import utils -from backoffice.workflows.constants import ResolutionDags, StatusChoices, WorkflowType -from backoffice.workflows.documents import WorkflowDocument -from backoffice.workflows.models import Decision, Workflow, WorkflowTicket +from backoffice.authors.api import utils +from backoffice.authors.constants import DECISION_CHOICES, StatusChoices, WorkflowType +from backoffice.authors.documents import AuthorWorkflowDocument +from backoffice.authors.models import ( + AuthorDecision, + AuthorWorkflow, + AuthorWorkflowTicket, +) -class WorkflowTicketSerializer(serializers.ModelSerializer): +class AuthorWorkflowTicketSerializer(serializers.ModelSerializer): ticket_url = serializers.SerializerMethodField() - workflow = serializers.PrimaryKeyRelatedField(queryset=Workflow.objects.all()) + workflow = serializers.PrimaryKeyRelatedField(queryset=AuthorWorkflow.objects.all()) class Meta: - model = WorkflowTicket + model = AuthorWorkflowTicket fields = "__all__" def get_ticket_url(self, obj): @@ -26,26 +29,11 @@ def get_ticket_url(self, obj): ) -class DecisionSerializer(serializers.ModelSerializer): - workflow = serializers.PrimaryKeyRelatedField(queryset=Workflow.objects.all()) - - class Meta: - model = Decision - fields = "__all__" - - -class WorkflowSerializer(serializers.ModelSerializer): - tickets = WorkflowTicketSerializer(many=True, read_only=True) - decisions = DecisionSerializer(many=True, read_only=True) - - class Meta: - model = Workflow - fields = "__all__" - +class AuthorDecisionSerializer(serializers.ModelSerializer): + workflow = serializers.PrimaryKeyRelatedField(queryset=AuthorWorkflow.objects.all()) -class WorkflowDocumentSerializer(DocumentSerializer): class Meta: - document = WorkflowDocument + model = AuthorDecision fields = "__all__" @@ -69,7 +57,9 @@ class Meta: ), ], ) -class WorkflowAuthorSerializer(WorkflowSerializer): +class AuthorWorkflowSerializer(serializers.ModelSerializer): + tickets = AuthorWorkflowTicketSerializer(many=True, read_only=True) + decisions = AuthorDecisionSerializer(many=True, read_only=True) data = serializers.JSONField(required=True) workflow_type = serializers.ChoiceField( choices=[ @@ -88,6 +78,34 @@ def validate_data(self, value): raise serializers.ValidationError(validation_errors_msg) return value + class Meta: + model = AuthorWorkflow + fields = "__all__" + + +@extend_schema_serializer( + exclude_fields=[ + "_created_at", + "_updated_at", + ], # Exclude internal fields from schema + examples=[ + OpenApiExample( + "Author Workflow Serializer", + summary="Author Workflow Serializer no data", + description="Author Workflow Serializer", + value={ + "workflow_type": WorkflowType.AUTHOR_CREATE, + "status": StatusChoices.RUNNING, + "data": {}, + }, + ), + ], +) +class AuthorWorkflowDocumentSerializer(DocumentSerializer): + class Meta: + document = AuthorWorkflowDocument + fields = "__all__" + @extend_schema_serializer( examples=[ @@ -104,5 +122,5 @@ def validate_data(self, value): ], ) class AuthorResolutionSerializer(serializers.Serializer): - value = serializers.ChoiceField(choices=ResolutionDags) + value = serializers.ChoiceField(choices=DECISION_CHOICES) create_ticket = serializers.BooleanField(default=False) diff --git a/backoffice/backoffice/workflows/api/utils.py b/backoffice/backoffice/authors/api/utils.py similarity index 81% rename from backoffice/backoffice/workflows/api/utils.py rename to backoffice/backoffice/authors/api/utils.py index fecf843690..2177930c67 100644 --- a/backoffice/backoffice/workflows/api/utils.py +++ b/backoffice/backoffice/authors/api/utils.py @@ -1,8 +1,8 @@ -from backoffice.workflows.api import serializers +from backoffice.authors.api.serializers import AuthorDecisionSerializer def add_decision(workflow_id, user, action): - serializer_class = serializers.DecisionSerializer + serializer_class = AuthorDecisionSerializer data = {"workflow": workflow_id, "user": user, "action": action} serializer = serializer_class(data=data) diff --git a/backoffice/backoffice/workflows/api/views.py b/backoffice/backoffice/authors/api/views.py similarity index 84% rename from backoffice/backoffice/workflows/api/views.py rename to backoffice/backoffice/authors/api/views.py index 4cf903f75c..9bf64693c2 100644 --- a/backoffice/backoffice/workflows/api/views.py +++ b/backoffice/backoffice/authors/api/views.py @@ -24,59 +24,34 @@ from rest_framework.response import Response from backoffice.utils.pagination import OSStandardResultsSetPagination -from backoffice.workflows import airflow_utils -from backoffice.workflows.api import utils -from backoffice.workflows.api.serializers import ( +from backoffice.authors import airflow_utils +from backoffice.authors.api import utils +from backoffice.authors.api.serializers import ( + AuthorDecisionSerializer, AuthorResolutionSerializer, - DecisionSerializer, - WorkflowAuthorSerializer, - WorkflowDocumentSerializer, - WorkflowSerializer, - WorkflowTicketSerializer, + AuthorWorkflowDocumentSerializer, + AuthorWorkflowSerializer, + AuthorWorkflowTicketSerializer, ) -from backoffice.workflows.constants import ( +from backoffice.authors.constants import ( WORKFLOW_DAGS, - ResolutionDags, + AuthorResolutionDags, StatusChoices, WorkflowType, ) -from backoffice.workflows.documents import WorkflowDocument -from backoffice.workflows.models import Decision, Workflow, WorkflowTicket +from backoffice.authors.documents import AuthorWorkflowDocument +from backoffice.authors.models import ( + AuthorDecision, + AuthorWorkflow, + AuthorWorkflowTicket, +) logger = logging.getLogger(__name__) -class WorkflowViewSet(viewsets.ModelViewSet): - queryset = Workflow.objects.all() - serializer_class = WorkflowSerializer - - def get_queryset(self): - status = self.request.query_params.get("status") - if status: - return self.queryset.filter(status__status=status) - return self.queryset - - def perform_destroy(self, instance): - airflow_utils.delete_workflow_dag_runs(instance.id, instance.workflow_type) - super().perform_destroy(instance) - - def retrieve(self, request, *args, **kwargs): - instance = self.get_object() - serializer = self.get_serializer(instance) - validation_errors = list(get_validation_errors(instance.data)) - validation_errors_msg = utils.render_validation_error_response( - validation_errors - ) - response_data = { - "data": serializer.data, - "validation_errors": validation_errors_msg, - } - return Response(response_data) - - -class WorkflowTicketViewSet(viewsets.ModelViewSet): - serializer_class = WorkflowTicketSerializer - queryset = WorkflowTicket.objects.all() +class AuthorWorkflowTicketViewSet(viewsets.ModelViewSet): + serializer_class = AuthorWorkflowTicketSerializer + queryset = AuthorWorkflowTicket.objects.all() def retrieve(self, request, *args, **kwargs): workflow_id = kwargs.get("pk") @@ -89,12 +64,12 @@ def retrieve(self, request, *args, **kwargs): ) try: - workflow_ticket = WorkflowTicket.objects.get( + workflow_ticket = AuthorWorkflowTicket.objects.get( workflow=workflow_id, ticket_type=ticket_type ) serializer = self.serializer_class(workflow_ticket) return Response(serializer.data) - except WorkflowTicket.DoesNotExist: + except AuthorWorkflowTicket.DoesNotExist: return Response( {"error": "Workflow ticket not found."}, status=status.HTTP_404_NOT_FOUND, @@ -108,9 +83,9 @@ def create(self, request, *args, **kwargs): return Response(serializer.data, status=status.HTTP_201_CREATED) -class DecisionViewSet(viewsets.ModelViewSet): - serializer_class = DecisionSerializer - queryset = Decision.objects.all() +class AuthorDecisionViewSet(viewsets.ModelViewSet): + serializer_class = AuthorDecisionSerializer + queryset = AuthorDecision.objects.all() def create(self, request, *args, **kwargs): data = utils.add_decision( @@ -119,8 +94,21 @@ def create(self, request, *args, **kwargs): return Response(data, status=status.HTTP_201_CREATED) -class AuthorWorkflowViewSet(viewsets.ViewSet): - serializer_class = WorkflowAuthorSerializer +class AuthorWorkflowViewSet(viewsets.ModelViewSet): + queryset = AuthorWorkflow.objects.all() + serializer_class = AuthorWorkflowSerializer + resolution_serializer = AuthorResolutionSerializer + resolution_dags = AuthorResolutionDags + + def get_queryset(self): + status = self.request.query_params.get("status") + if status: + return self.queryset.filter(status__status=status) + return self.queryset + + def perform_destroy(self, instance): + airflow_utils.delete_workflow_dag_runs(instance.id, instance.workflow_type) + super().perform_destroy(instance) @extend_schema( summary="Create/Update an Author", @@ -133,7 +121,7 @@ def create(self, request): serializer = self.serializer_class(data=request.data) serializer.is_valid(raise_exception=True) logger.info("Data passed schema validation, creating workflow.") - workflow = Workflow.objects.create( + workflow = AuthorWorkflow.objects.create( data=serializer.validated_data["data"], workflow_type=serializer.validated_data["workflow_type"], ) @@ -150,8 +138,8 @@ def create(self, request): return Response(serializer.data, status=status.HTTP_201_CREATED) @extend_schema( - summary="Partially Updates Author", - description="Updates specific fields of the author.", + summary="Partially Updates Author Workflow", + description="Updates specific fields of the author workflow.", examples=[ OpenApiExample( "Status Update", @@ -163,7 +151,7 @@ def create(self, request): ) def partial_update(self, request, pk=None): logger.info("Updating workflow with data: %s", request.data) - workflow_instance = get_object_or_404(Workflow, pk=pk) + workflow_instance = get_object_or_404(AuthorWorkflow, pk=pk) serializer = self.serializer_class( workflow_instance, data=request.data, partial=True ) @@ -180,21 +168,23 @@ def partial_update(self, request, pk=None): @action(detail=True, methods=["post"]) def resolve(self, request, pk=None): logger.info("Resolving data: %s", request.data) - serializer = AuthorResolutionSerializer(data=request.data) + serializer = self.resolution_serializer(data=request.data) if serializer.is_valid(raise_exception=True): extra_data = serializer.validated_data logger.info( "Trigger Airflow DAG: %s for %s", - ResolutionDags[serializer.validated_data["value"]], + AuthorResolutionDags[serializer.validated_data["value"]], pk, ) utils.add_decision(pk, request.user, serializer.validated_data["value"]) airflow_utils.trigger_airflow_dag( - ResolutionDags[serializer.validated_data["value"]].label, pk, extra_data + AuthorResolutionDags[serializer.validated_data["value"]].label, + pk, + extra_data, ) workflow_serializer = self.serializer_class( - get_object_or_404(Workflow, pk=pk) + get_object_or_404(AuthorWorkflow, pk=pk) ) return Response(workflow_serializer.data) @@ -219,14 +209,14 @@ def resolve(self, request, pk=None): ) @action(detail=True, methods=["post"]) def restart(self, request, pk=None): - workflow = Workflow.objects.get(id=pk) + workflow = AuthorWorkflow.objects.get(id=pk) if request.data.get("restart_current_task"): return airflow_utils.restart_failed_tasks( workflow.id, workflow.workflow_type ) - Decision.objects.filter(workflow=workflow).delete() + AuthorDecision.objects.filter(workflow=workflow).delete() return airflow_utils.restart_workflow_dags( workflow.id, workflow.workflow_type, request.data.get("params") ) @@ -370,13 +360,13 @@ def validate(self, request): ], ), ) -class WorkflowDocumentView(BaseDocumentViewSet): +class AuthorWorkflowDocumentView(BaseDocumentViewSet): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.search = self.search.extra(track_total_hits=True) - document = WorkflowDocument - serializer_class = WorkflowSerializer + document = AuthorWorkflowDocument + serializer_class = AuthorWorkflowDocumentSerializer pagination_class = OSStandardResultsSetPagination filter_backends = [ DefaultOrderingFilterBackend, @@ -396,7 +386,6 @@ def __init__(self, *args, **kwargs): filter_fields = { "status": "status", "workflow_type": "workflow_type", - "is_update": "is_update", } ordering_fields = {"_updated_at": "_updated_at", "_score": "_score"} @@ -428,6 +417,3 @@ def __init__(self, *args, **kwargs): "enabled": True, }, } - - def get_serializer_class(self): - return WorkflowDocumentSerializer diff --git a/backoffice/backoffice/workflows/apps.py b/backoffice/backoffice/authors/apps.py similarity index 57% rename from backoffice/backoffice/workflows/apps.py rename to backoffice/backoffice/authors/apps.py index 2d83632c1e..4fb07997be 100644 --- a/backoffice/backoffice/workflows/apps.py +++ b/backoffice/backoffice/authors/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -class WorkflowsConfig(AppConfig): +class AuthorsConfig(AppConfig): default_auto_field = "django.db.models.BigAutoField" - name = "backoffice.workflows" + name = "backoffice.authors" diff --git a/backoffice/backoffice/workflows/constants.py b/backoffice/backoffice/authors/constants.py similarity index 88% rename from backoffice/backoffice/workflows/constants.py rename to backoffice/backoffice/authors/constants.py index b245b69b31..991883f2ca 100644 --- a/backoffice/backoffice/workflows/constants.py +++ b/backoffice/backoffice/authors/constants.py @@ -30,14 +30,19 @@ class WorkflowType(models.TextChoices): DEFAULT_WORKFLOW_TYPE = WorkflowType.HEP_CREATE +allowed_workflow_types = [ + WorkflowType.AUTHOR_CREATE, + WorkflowType.AUTHOR_UPDATE, +] -class ResolutionDags(models.TextChoices): + +class AuthorResolutionDags(models.TextChoices): accept = "accept", "author_create_approved_dag" reject = "reject", "author_create_rejected_dag" accept_curate = "accept_curate", "author_create_approved_dag" -DECISION_CHOICES = ResolutionDags.choices +DECISION_CHOICES = AuthorResolutionDags.choices class AuthorCreateDags(models.TextChoices): diff --git a/backoffice/backoffice/workflows/documents.py b/backoffice/backoffice/authors/documents.py similarity index 85% rename from backoffice/backoffice/workflows/documents.py rename to backoffice/backoffice/authors/documents.py index e2240d15f5..09b5c0b892 100644 --- a/backoffice/backoffice/workflows/documents.py +++ b/backoffice/backoffice/authors/documents.py @@ -2,11 +2,11 @@ from django_opensearch_dsl import Document, fields from django_opensearch_dsl.registries import registry -from backoffice.workflows.models import Workflow +from backoffice.authors.models import AuthorWorkflow @registry.register_document -class WorkflowDocument(Document): +class AuthorWorkflowDocument(Document): id = fields.TextField() workflow_type = fields.KeywordField() data = fields.ObjectField(dynamic=True) @@ -19,7 +19,6 @@ class WorkflowDocument(Document): ) status = fields.KeywordField() - is_update = fields.BooleanField() class Index: name = settings.OPENSEARCH_INDEX_NAMES[__name__] @@ -30,7 +29,7 @@ class Index: } class Django: - model = Workflow + model = AuthorWorkflow fields = [ "_created_at", "_updated_at", diff --git a/backoffice/backoffice/authors/migrations/0001_initial.py b/backoffice/backoffice/authors/migrations/0001_initial.py new file mode 100644 index 0000000000..ce9119f433 --- /dev/null +++ b/backoffice/backoffice/authors/migrations/0001_initial.py @@ -0,0 +1,142 @@ +# Generated by Django 4.2.6 on 2024-10-04 11:30 + +import uuid + +import django.db.models.deletion +from django.conf import settings +from django.db import migrations, models + + +class Migration(migrations.Migration): + initial = True + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ] + + operations = [ + migrations.CreateModel( + name="AuthorWorkflow", + fields=[ + ( + "id", + models.UUIDField( + default=uuid.uuid4, + editable=False, + primary_key=True, + serialize=False, + ), + ), + ( + "workflow_type", + models.CharField( + choices=[ + ("HEP_CREATE", "HEP create"), + ("HEP_UPDATE", "HEP update"), + ("AUTHOR_CREATE", "Author create"), + ("AUTHOR_UPDATE", "Author update"), + ], + default="HEP_CREATE", + max_length=30, + ), + ), + ("data", models.JSONField()), + ( + "status", + models.CharField( + choices=[ + ("running", "Running"), + ("approval", "Waiting for approva"), + ("completed", "Completed"), + ("error", "Error"), + ], + default="running", + max_length=30, + ), + ), + ("_created_at", models.DateTimeField(auto_now_add=True)), + ("_updated_at", models.DateTimeField(auto_now=True)), + ], + ), + migrations.CreateModel( + name="AuthorWorkflowTicket", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ("ticket_id", models.CharField(max_length=32)), + ( + "ticket_type", + models.CharField( + choices=[ + ("author_create_curation", "Author create curation"), + ("author_create_user", "Author create user"), + ("author_update_curation", "Author update curation"), + ], + default="author_create_curation", + max_length=30, + ), + ), + ("_created_at", models.DateTimeField(auto_now_add=True)), + ("_updated_at", models.DateTimeField(auto_now=True)), + ( + "workflow", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="tickets", + to="authors.authorworkflow", + ), + ), + ], + ), + migrations.CreateModel( + name="AuthorDecision", + fields=[ + ( + "id", + models.BigAutoField( + auto_created=True, + primary_key=True, + serialize=False, + verbose_name="ID", + ), + ), + ( + "action", + models.CharField( + choices=[ + ("accept", "author_create_approved_dag"), + ("reject", "author_create_rejected_dag"), + ("accept_curate", "author_create_approved_dag"), + ], + max_length=30, + ), + ), + ("_created_at", models.DateTimeField(auto_now_add=True)), + ("_updated_at", models.DateTimeField(auto_now=True)), + ( + "user", + models.ForeignKey( + db_column="email", + on_delete=django.db.models.deletion.CASCADE, + to=settings.AUTH_USER_MODEL, + to_field="email", + ), + ), + ( + "workflow", + models.ForeignKey( + on_delete=django.db.models.deletion.CASCADE, + related_name="decisions", + to="authors.authorworkflow", + ), + ), + ], + ), + ] diff --git a/backoffice/backoffice/workflows/api/__init__.py b/backoffice/backoffice/authors/migrations/__init__.py similarity index 100% rename from backoffice/backoffice/workflows/api/__init__.py rename to backoffice/backoffice/authors/migrations/__init__.py diff --git a/backoffice/backoffice/workflows/models.py b/backoffice/backoffice/authors/models.py similarity index 79% rename from backoffice/backoffice/workflows/models.py rename to backoffice/backoffice/authors/models.py index 3dfb7cb3df..270eecf6bf 100644 --- a/backoffice/backoffice/workflows/models.py +++ b/backoffice/backoffice/authors/models.py @@ -2,8 +2,7 @@ from django.db import models -from backoffice.users.models import User -from backoffice.workflows.constants import ( +from backoffice.authors.constants import ( DECISION_CHOICES, DEFAULT_STATUS_CHOICE, DEFAULT_TICKET_TYPE, @@ -12,9 +11,10 @@ StatusChoices, WorkflowType, ) +from backoffice.users.models import User -class Workflow(models.Model): +class AuthorWorkflow(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) workflow_type = models.CharField( @@ -28,16 +28,14 @@ class Workflow(models.Model): choices=StatusChoices.choices, default=DEFAULT_STATUS_CHOICE, ) - core = models.BooleanField(default=False) - is_update = models.BooleanField(default=False) _created_at = models.DateTimeField(auto_now_add=True) _updated_at = models.DateTimeField(auto_now=True) -class WorkflowTicket(models.Model): +class AuthorWorkflowTicket(models.Model): workflow = models.ForeignKey( - Workflow, related_name="tickets", on_delete=models.CASCADE + AuthorWorkflow, related_name="tickets", on_delete=models.CASCADE ) ticket_id = models.CharField( max_length=32, null=False, blank=False @@ -49,7 +47,7 @@ class WorkflowTicket(models.Model): _updated_at = models.DateTimeField(auto_now=True) -class Decision(models.Model): +class AuthorDecision(models.Model): user = models.ForeignKey( User, to_field="email", @@ -57,7 +55,7 @@ class Decision(models.Model): on_delete=models.CASCADE, ) workflow = models.ForeignKey( - Workflow, related_name="decisions", on_delete=models.CASCADE + AuthorWorkflow, related_name="decisions", on_delete=models.CASCADE ) action = models.CharField(max_length=30, choices=DECISION_CHOICES) diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag_runs.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag_runs.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag_runs.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_delete_workflow_dag_runs.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_fetch_data_workflow_dag.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_fetch_data_workflow_dag.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_fetch_data_workflow_dag.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_fetch_data_workflow_dag.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_executed_dags.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_find_executed_dags.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_executed_dags.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_find_executed_dags.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_find_failed_dag.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks_no_tasks.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks_no_tasks.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks_no_tasks.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_restart_failed_tasks_no_tasks.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_workflow_dags.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_restart_workflow_dags.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_restart_workflow_dags.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_restart_workflow_dags.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAirflowUtils.test_trigger_airflow_dag.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_accept_author.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_create_author.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_create_author.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_create_author.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_create_author.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_reject_author.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_a_task.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_a_task.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_a_task.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_a_task.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_full_dagrun.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_full_dagrun.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_full_dagrun.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_full_dagrun.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_with_params.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_with_params.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_with_params.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_restart_with_params.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_invalid_schema_record.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_invalid_schema_record.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_invalid_schema_record.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_invalid_schema_record.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_no_schema_record.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_no_schema_record.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_no_schema_record.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_no_schema_record.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_not_valid_record.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_not_valid_record.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_not_valid_record.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_not_valid_record.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_valid_record.yaml b/backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_valid_record.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_valid_record.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestAuthorWorkflowViewSet.test_validate_valid_record.yaml diff --git a/backoffice/backoffice/workflows/tests/cassettes/TestWorkflowViewSet.test_delete.yaml b/backoffice/backoffice/authors/tests/cassettes/TestWorkflowViewSet.test_delete.yaml similarity index 100% rename from backoffice/backoffice/workflows/tests/cassettes/TestWorkflowViewSet.test_delete.yaml rename to backoffice/backoffice/authors/tests/cassettes/TestWorkflowViewSet.test_delete.yaml diff --git a/backoffice/backoffice/workflows/tests/conftest.py b/backoffice/backoffice/authors/tests/conftest.py similarity index 100% rename from backoffice/backoffice/workflows/tests/conftest.py rename to backoffice/backoffice/authors/tests/conftest.py diff --git a/backoffice/backoffice/workflows/tests/test_airflow_utils.py b/backoffice/backoffice/authors/tests/test_airflow_utils.py similarity index 83% rename from backoffice/backoffice/workflows/tests/test_airflow_utils.py rename to backoffice/backoffice/authors/tests/test_airflow_utils.py index b36bbc228c..073330fa6a 100644 --- a/backoffice/backoffice/workflows/tests/test_airflow_utils.py +++ b/backoffice/backoffice/authors/tests/test_airflow_utils.py @@ -1,13 +1,10 @@ import uuid import pytest -from backoffice.workflows import airflow_utils -from backoffice.workflows.constants import WORKFLOW_DAGS, WorkflowType -from django.apps import apps +from backoffice.authors import airflow_utils +from backoffice.authors.constants import WORKFLOW_DAGS, WorkflowType from django.test import TransactionTestCase -Workflow = apps.get_model(app_label="workflows", model_name="Workflow") - class TestAirflowUtils(TransactionTestCase): def setUp(self): @@ -21,25 +18,25 @@ def setUp(self): def tearDown(self): airflow_utils.delete_workflow_dag(self.dag_id, self.workflow_id) - @pytest.mark.vcr() + @pytest.mark.vcr def test_trigger_airflow_dag(self): self.assertEqual(self.response.status_code, 200) - @pytest.mark.vcr() + @pytest.mark.vcr def test_restart_failed_tasks(self): response = airflow_utils.restart_failed_tasks( self.workflow_id, self.workflow_type ) self.assertEqual(response.status_code, 200) - @pytest.mark.vcr() + @pytest.mark.vcr def test_restart_failed_tasks_no_tasks(self): response = airflow_utils.restart_failed_tasks( self.workflow_id, self.workflow_type ) self.assertEqual(response.status_code, 200) - @pytest.mark.vcr() + @pytest.mark.vcr def test_find_executed_dags(self): executed_dags_for_workflow = airflow_utils.find_executed_dags( self.workflow_id, self.workflow_type @@ -47,28 +44,28 @@ def test_find_executed_dags(self): self.assertIn(self.dag_id, executed_dags_for_workflow) - @pytest.mark.vcr() + @pytest.mark.vcr def test_find_failed_dag(self): failed_dag = airflow_utils.find_failed_dag(self.workflow_id, self.workflow_type) self.assertEqual(self.dag_id, failed_dag) - @pytest.mark.vcr() + @pytest.mark.vcr def test_delete_workflow_dag(self): response = airflow_utils.delete_workflow_dag(self.dag_id, self.workflow_id) self.assertEqual(response.status_code, 200) - @pytest.mark.vcr() + @pytest.mark.vcr def test_restart_workflow_dags(self): response = airflow_utils.restart_workflow_dags( self.workflow_id, self.workflow_type ) self.assertEqual(response.status_code, 200) - @pytest.mark.vcr() + @pytest.mark.vcr def test_delete_workflow_dag_runs(self): airflow_utils.delete_workflow_dag_runs(self.workflow_id, self.workflow_type) - @pytest.mark.vcr() + @pytest.mark.vcr def test_fetch_data_workflow_dag(self): result = airflow_utils.fetch_data_workflow_dag( self.workflow_id, self.workflow_type diff --git a/backoffice/backoffice/workflows/tests/test_utils.py b/backoffice/backoffice/authors/tests/test_utils.py similarity index 64% rename from backoffice/backoffice/workflows/tests/test_utils.py rename to backoffice/backoffice/authors/tests/test_utils.py index c25ef9e16a..91a54e0612 100644 --- a/backoffice/backoffice/workflows/tests/test_utils.py +++ b/backoffice/backoffice/authors/tests/test_utils.py @@ -1,16 +1,16 @@ import uuid import pytest -from backoffice.workflows import constants -from backoffice.workflows.api import utils -from backoffice.workflows.constants import StatusChoices +from backoffice.authors import constants +from backoffice.authors.api import utils +from backoffice.authors.constants import StatusChoices from django.apps import apps from django.contrib.auth import get_user_model from django.test import TransactionTestCase from rest_framework.exceptions import ValidationError User = get_user_model() -Workflow = apps.get_model(app_label="workflows", model_name="Workflow") +AuthorWorkflow = apps.get_model(app_label="authors", model_name="AuthorWorkflow") class TestUtils(TransactionTestCase): @@ -19,8 +19,8 @@ class TestUtils(TransactionTestCase): def setUp(self): super().setUp() - self.workflow = Workflow.objects.create( - data={}, status=StatusChoices.APPROVAL, core=True, is_update=False + self.workflow = AuthorWorkflow.objects.create( + data={}, status=StatusChoices.APPROVAL ) self.user = User.objects.create_user( email="testuser@test.com", password="12345" @@ -28,7 +28,7 @@ def setUp(self): def test_add_decision(self): decision_data = utils.add_decision( - self.workflow.id, self.user, constants.ResolutionDags.accept + self.workflow.id, self.user, constants.AuthorResolutionDags.accept ) self.assertIsNotNone(decision_data) @@ -39,5 +39,5 @@ def test_add_decision_validation_errors(self): with pytest.raises(ValidationError): utils.add_decision( - uuid.UUID(int=0), self.user, constants.ResolutionDags.accept + uuid.UUID(int=0), self.user, constants.AuthorResolutionDags.accept ) diff --git a/backoffice/backoffice/workflows/tests/test_views.py b/backoffice/backoffice/authors/tests/test_views.py similarity index 87% rename from backoffice/backoffice/workflows/tests/test_views.py rename to backoffice/backoffice/authors/tests/test_views.py index c12971b4c9..2b535731b6 100644 --- a/backoffice/backoffice/workflows/tests/test_views.py +++ b/backoffice/backoffice/authors/tests/test_views.py @@ -5,19 +5,19 @@ import dateutil.parser import opensearchpy import pytest -from backoffice.workflows import airflow_utils -from backoffice.workflows.api.serializers import ( - WorkflowSerializer, - WorkflowTicketSerializer, +from backoffice.authors import airflow_utils +from backoffice.authors.api.serializers import ( + AuthorWorkflowTicketSerializer, + AuthorWorkflowSerializer, ) -from backoffice.workflows.constants import ( +from backoffice.authors.constants import ( WORKFLOW_DAGS, AuthorCreateDags, - ResolutionDags, + AuthorResolutionDags, StatusChoices, WorkflowType, ) -from backoffice.workflows.models import WorkflowTicket +from backoffice.authors.models import AuthorWorkflowTicket from django.apps import apps from django.contrib.auth import get_user_model from django.contrib.auth.models import Group @@ -29,8 +29,8 @@ from rest_framework.test import APIClient User = get_user_model() -Workflow = apps.get_model(app_label="workflows", model_name="Workflow") -Decision = apps.get_model(app_label="workflows", model_name="Decision") +AuthorWorkflow = apps.get_model(app_label="authors", model_name="AuthorWorkflow") +AuthorDecision = apps.get_model(app_label="authors", model_name="AuthorDecision") class BaseTransactionTestCase(TransactionTestCase): @@ -62,11 +62,9 @@ class TestWorkflowViewSet(BaseTransactionTestCase): def setUp(self): super().setUp() - self.workflow = Workflow.objects.create( + self.workflow = AuthorWorkflow.objects.create( data={}, status=StatusChoices.APPROVAL, - core=True, - is_update=False, workflow_type=WorkflowType.AUTHOR_CREATE, id=uuid.UUID(int=2), ) @@ -92,25 +90,25 @@ def test_list_anonymous(self): self.assertEqual(response.status_code, 403) def test_tickets(self): - WorkflowTicket.objects.create( + AuthorWorkflowTicket.objects.create( workflow=self.workflow, ticket_id="123", ticket_type="author_create_user" ) - workflow_data = WorkflowSerializer(self.workflow).data + workflow_data = AuthorWorkflowSerializer(self.workflow).data assert "tickets" in workflow_data assert "ticket_id" in workflow_data["tickets"][0] assert "ticket_type" in workflow_data["tickets"][0] def test_decisions(self): - Decision.objects.create( - workflow=self.workflow, user=self.user, action=ResolutionDags.accept + AuthorDecision.objects.create( + workflow=self.workflow, user=self.user, action=AuthorResolutionDags.accept ) - workflow_data = WorkflowSerializer(self.workflow).data + workflow_data = AuthorWorkflowSerializer(self.workflow).data assert "decisions" in workflow_data assert "action" in workflow_data["decisions"][0] assert "user" in workflow_data["decisions"][0] - @pytest.mark.vcr() + @pytest.mark.vcr def test_delete(self): self.api_client.force_authenticate(user=self.curator) airflow_utils.trigger_airflow_dag( @@ -145,8 +143,8 @@ def setUp(self): index.delete() index.create() - self.workflow = Workflow.objects.create( - data={}, status=StatusChoices.APPROVAL, core=True, is_update=False + self.workflow = AuthorWorkflow.objects.create( + data={}, status=StatusChoices.APPROVAL ) def test_list_curator(self): @@ -183,8 +181,8 @@ class TestAuthorWorkflowPartialUpdateViewSet(BaseTransactionTestCase): def setUp(self): super().setUp() - self.workflow = Workflow.objects.create( - data={}, status=StatusChoices.APPROVAL, core=True, is_update=False + self.workflow = AuthorWorkflow.objects.create( + data={}, status=StatusChoices.APPROVAL ) @property @@ -201,7 +199,7 @@ def test_patch_curator(self): ) self.assertEqual(response.status_code, 200) - workflow = Workflow.objects.filter(id=self.workflow.id)[0] + workflow = AuthorWorkflow.objects.filter(id=self.workflow.id)[0] assert workflow.status == "running" def test_patch_admin(self): @@ -219,7 +217,8 @@ def test_patch_admin(self): }, }, ) - workflow = Workflow.objects.filter(id=self.workflow.id)[0] + + workflow = AuthorWorkflow.objects.filter(id=self.workflow.id)[0] self.assertEqual(response.status_code, 200) self.assertEqual(workflow.status, "approval") self.assertEqual( @@ -236,24 +235,22 @@ def test_patch_anonymous(self): self.assertEqual(response.status_code, 403) -class TestWorkflowTicketViewSet(BaseTransactionTestCase): +class TestAuthorWorkflowTicketViewSet(BaseTransactionTestCase): endpoint = "/api/workflow-ticket" reset_sequences = True fixtures = ["backoffice/fixtures/groups.json"] def setUp(self): super().setUp() - self.workflow = Workflow.objects.create( - data={}, status="running", core=True, is_update=False - ) - self.workflow_ticket = WorkflowTicket.objects.create( + self.workflow = AuthorWorkflow.objects.create(data={}, status="running") + self.workflow_ticket = AuthorWorkflowTicket.objects.create( workflow=self.workflow, ticket_id="123", ticket_type="author_create_user" ) def test_get_missing_params(self): self.api_client.force_authenticate(user=self.curator) response = self.api_client.get( - f"{TestWorkflowTicketViewSet.endpoint}/{self.workflow.id}/", + f"{TestAuthorWorkflowTicketViewSet.endpoint}/{self.workflow.id}/", format="json", data={}, ) @@ -265,7 +262,7 @@ def test_get_ticket_not_found(self): query_params = {"ticket_type": "test"} self.api_client.force_authenticate(user=self.curator) response = self.api_client.get( - f"{TestWorkflowTicketViewSet.endpoint}/{self.workflow.id}/", + f"{TestAuthorWorkflowTicketViewSet.endpoint}/{self.workflow.id}/", format="json", data=query_params, ) @@ -278,21 +275,23 @@ def test_get_ticket_happy_flow(self): query_params = {"ticket_type": self.workflow_ticket.ticket_type} response = self.api_client.get( - f"{TestWorkflowTicketViewSet.endpoint}/{self.workflow.id}/", + f"{TestAuthorWorkflowTicketViewSet.endpoint}/{self.workflow.id}/", format="json", data=query_params, ) assert response.status_code == 200 - assert response.data == WorkflowTicketSerializer(self.workflow_ticket).data + assert ( + response.data == AuthorWorkflowTicketSerializer(self.workflow_ticket).data + ) def test_ticket_url(self): - assert "ticket_url" in WorkflowTicketSerializer(self.workflow_ticket).data + assert "ticket_url" in AuthorWorkflowTicketSerializer(self.workflow_ticket).data def test_create_missing_params(self): self.api_client.force_authenticate(user=self.curator) response = self.api_client.post( - f"{TestWorkflowTicketViewSet.endpoint}/", format="json", data={} + f"{TestAuthorWorkflowTicketViewSet.endpoint}/", format="json", data={} ) assert response.status_code == 400 @@ -310,7 +309,7 @@ def test_create_happy_flow(self): "ticket_type": "author_create_user", } response = self.api_client.post( - f"{TestWorkflowTicketViewSet.endpoint}/", format="json", data=data + f"{TestAuthorWorkflowTicketViewSet.endpoint}/", format="json", data=data ) assert response.status_code == 201 @@ -321,7 +320,7 @@ def test_create_happy_flow(self): assert ( response.data - == WorkflowTicketSerializer(WorkflowTicket.objects.last()).data + == AuthorWorkflowTicketSerializer(AuthorWorkflowTicket.objects.last()).data ) @@ -333,11 +332,9 @@ class TestAuthorWorkflowViewSet(BaseTransactionTestCase): def setUp(self): super().setUp() - self.workflow = Workflow.objects.create( + self.workflow = AuthorWorkflow.objects.create( data={"test": "test"}, status="running", - core=True, - is_update=False, workflow_type=WorkflowType.AUTHOR_CREATE, id=uuid.UUID(int=0), ) @@ -353,7 +350,7 @@ def tearDown(self): WORKFLOW_DAGS[self.workflow.workflow_type].initialize, self.workflow.id ) - @pytest.mark.vcr() + @pytest.mark.vcr def test_create_author(self): self.api_client.force_authenticate(user=self.curator) @@ -374,7 +371,7 @@ def test_create_author(self): self.assertEqual(response.status_code, 201) self.assertEqual(response.json(), data) - @pytest.mark.vcr() + @pytest.mark.vcr def test_accept_author(self): self.api_client.force_authenticate(user=self.curator) action = "accept" @@ -388,7 +385,7 @@ def test_accept_author(self): self.assertEqual(response.status_code, 200) self.assertEqual( - Decision.objects.filter(workflow=self.workflow.id)[0].action, action + AuthorDecision.objects.filter(workflow=self.workflow.id)[0].action, action ) self.assertEqual(response.json()["id"], str(self.workflow.id)) self.assertIn("decisions", response.json()) @@ -396,7 +393,7 @@ def test_accept_author(self): WORKFLOW_DAGS[WorkflowType.AUTHOR_CREATE].approve, self.workflow.id ) - @pytest.mark.vcr() + @pytest.mark.vcr def test_reject_author(self): self.api_client.force_authenticate(user=self.curator) action = "reject" @@ -410,7 +407,7 @@ def test_reject_author(self): self.assertEqual(response.status_code, 200) self.assertEqual( - Decision.objects.filter(workflow=self.workflow.id)[0].action, action + AuthorDecision.objects.filter(workflow=self.workflow.id)[0].action, action ) self.assertEqual(response.json()["id"], str(self.workflow.id)) self.assertIn("decisions", response.json()) @@ -419,7 +416,7 @@ def test_reject_author(self): WORKFLOW_DAGS[WorkflowType.AUTHOR_CREATE].reject, self.workflow.id ) - @pytest.mark.vcr() + @pytest.mark.vcr def test_restart_full_dagrun(self): self.api_client.force_authenticate(user=self.curator) url = reverse( @@ -430,7 +427,7 @@ def test_restart_full_dagrun(self): self.assertEqual(response.status_code, 200) self.assertIn("test", response.json()["conf"]["data"]) - @pytest.mark.vcr() + @pytest.mark.vcr def test_restart_a_task(self): self.api_client.force_authenticate(user=self.curator) url = reverse( @@ -442,7 +439,7 @@ def test_restart_a_task(self): ) self.assertEqual(response.status_code, 200) - @pytest.mark.vcr() + @pytest.mark.vcr def test_restart_with_params(self): self.api_client.force_authenticate(user=self.curator) url = reverse( @@ -454,7 +451,7 @@ def test_restart_with_params(self): ) self.assertEqual(response.status_code, 200) - @pytest.mark.vcr() + @pytest.mark.vcr def test_validate_valid_record(self): self.api_client.force_authenticate(user=self.curator) data = { @@ -470,7 +467,7 @@ def test_validate_valid_record(self): response = self.api_client.post(url, format="json", data=data) self.assertContains(response, "Record is valid.", status_code=200) - @pytest.mark.vcr() + @pytest.mark.vcr def test_validate_not_valid_record(self): self.api_client.force_authenticate(user=self.curator) data = { @@ -499,7 +496,7 @@ def test_validate_not_valid_record(self): self.assertEqual(response.status_code, 400) self.assertEqual(response.json(), expected_response) - @pytest.mark.vcr() + @pytest.mark.vcr def test_validate_no_schema_record(self): self.api_client.force_authenticate(user=self.curator) url = reverse( @@ -512,7 +509,7 @@ def test_validate_no_schema_record(self): status_code=400, ) - @pytest.mark.vcr() + @pytest.mark.vcr def test_validate_invalid_schema_record(self): self.api_client.force_authenticate(user=self.curator) data = { @@ -543,7 +540,7 @@ def setUpClass(cls): index.delete() index.create() - Workflow.objects.update_or_create( + AuthorWorkflow.objects.update_or_create( data={ "ids": [ {"value": "0000-0003-3302-3333", "schema": "ORCID"}, @@ -555,11 +552,9 @@ def setUpClass(cls): ], }, status=StatusChoices.APPROVAL, - core=True, - is_update=False, workflow_type=WorkflowType.AUTHOR_CREATE, ) - Workflow.objects.update_or_create( + AuthorWorkflow.objects.update_or_create( data={ "ids": [ {"value": "0000-0003-3302-2222", "schema": "ORCID"}, @@ -571,8 +566,6 @@ def setUpClass(cls): ], }, status=StatusChoices.RUNNING, - core=True, - is_update=False, workflow_type=WorkflowType.AUTHOR_CREATE, ) @@ -674,9 +667,7 @@ class TestDecisionsViewSet(BaseTransactionTestCase): def setUp(self): super().setUp() - self.workflow = Workflow.objects.create( - data={}, status="running", core=True, is_update=False - ) + self.workflow = AuthorWorkflow.objects.create(data={}, status="running") def test_create_decision(self): self.api_client.force_authenticate(user=self.curator) diff --git a/backoffice/backoffice/authors/urls.py b/backoffice/backoffice/authors/urls.py new file mode 100644 index 0000000000..6b429b9df8 --- /dev/null +++ b/backoffice/backoffice/authors/urls.py @@ -0,0 +1,18 @@ +from django.conf import settings +from rest_framework.routers import DefaultRouter, SimpleRouter + +from backoffice.authors.api.views import ( + AuthorDecisionViewSet, + AuthorWorkflowTicketViewSet, + AuthorWorkflowViewSet, +) + +router = DefaultRouter() if settings.DEBUG else SimpleRouter() + +# Workflows +router.register("authors", AuthorWorkflowViewSet, basename="authors") +router.register( + "authors/tickets", AuthorWorkflowTicketViewSet, basename="author-tickets" +) +router.register("authors/decisions", AuthorDecisionViewSet, basename="author-decisions") +app_name = "authors" diff --git a/backoffice/backoffice/management/management/commands/create_groups.py b/backoffice/backoffice/management/management/commands/create_groups.py index bb6154c39e..0113d61832 100644 --- a/backoffice/backoffice/management/management/commands/create_groups.py +++ b/backoffice/backoffice/management/management/commands/create_groups.py @@ -2,7 +2,7 @@ from django.contrib.contenttypes.models import ContentType from django.core.management.base import BaseCommand -from backoffice.workflows.models import Workflow +from backoffice.authors.models import AuthorWorkflow class Command(BaseCommand): @@ -17,7 +17,7 @@ def handle(self, *args, **options): admin_group, _ = Group.objects.get_or_create(name="admin") curator_group, _ = Group.objects.get_or_create(name="curator") - content_type = ContentType.objects.get_for_model(Workflow) + content_type = ContentType.objects.get_for_model(AuthorWorkflow) permissions = Permission.objects.filter(content_type=content_type) admin_group.permissions.add(*permissions) curator_group.permissions.add(*permissions) diff --git a/backoffice/backoffice/management/tests/test_commands.py b/backoffice/backoffice/management/tests/test_commands.py index 9828cf3151..5dd795e07d 100644 --- a/backoffice/backoffice/management/tests/test_commands.py +++ b/backoffice/backoffice/management/tests/test_commands.py @@ -1,4 +1,4 @@ -from backoffice.workflows.models import Workflow +from backoffice.authors.models import AuthorWorkflow from django.contrib.auth.models import Group, Permission from django.contrib.contenttypes.models import ContentType from django.core.management import call_command @@ -12,7 +12,7 @@ def test_handle(self): admin_group = Group.objects.get(name="admin") curator_group = Group.objects.get(name="curator") - content_type = ContentType.objects.get_for_model(Workflow) + content_type = ContentType.objects.get_for_model(AuthorWorkflow) permissions = Permission.objects.filter(content_type=content_type) self.assertTrue(admin_group.permissions.all().count() == permissions.count()) diff --git a/backoffice/backoffice/workflows/migrations/0001_initial.py b/backoffice/backoffice/workflows/migrations/0001_initial.py deleted file mode 100644 index faa4704b36..0000000000 --- a/backoffice/backoffice/workflows/migrations/0001_initial.py +++ /dev/null @@ -1,72 +0,0 @@ -# Generated by Django 4.2.6 on 2023-10-16 09:06 - -import uuid - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - initial = True - - dependencies = [] - - operations = [ - migrations.CreateModel( - name="WorkflowData", - fields=[ - ( - "id", - models.UUIDField( - default=uuid.uuid4, - editable=False, - primary_key=True, - serialize=False, - ), - ), - ("data", models.JSONField()), - ], - ), - migrations.CreateModel( - name="WorkflowMeta", - fields=[ - ( - "id", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - primary_key=True, - serialize=False, - to="workflows.workflowdata", - ), - ), - ("core", models.BooleanField()), - ("is_update", models.BooleanField()), - ], - ), - migrations.CreateModel( - name="WorkflowStatus", - fields=[ - ( - "id", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - primary_key=True, - serialize=False, - to="workflows.workflowdata", - ), - ), - ( - "status", - models.CharField( - choices=[ - ("PREPROCESSING", "Preprocessing"), - ("APPROVAL", "Approval"), - ("POSTPROCESSING", "Postprocessing"), - ], - default="PREPROCESSING", - max_length=30, - ), - ), - ], - ), - ] diff --git a/backoffice/backoffice/workflows/migrations/0002_workflow_remove_workflowmeta_id_and_more.py b/backoffice/backoffice/workflows/migrations/0002_workflow_remove_workflowmeta_id_and_more.py deleted file mode 100644 index 1c426d8f37..0000000000 --- a/backoffice/backoffice/workflows/migrations/0002_workflow_remove_workflowmeta_id_and_more.py +++ /dev/null @@ -1,60 +0,0 @@ -# Generated by Django 4.2.6 on 2023-10-17 07:16 - -import uuid - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("workflows", "0001_initial"), - ] - - operations = [ - migrations.CreateModel( - name="Workflow", - fields=[ - ( - "id", - models.UUIDField( - default=uuid.uuid4, - editable=False, - primary_key=True, - serialize=False, - ), - ), - ("data", models.JSONField()), - ( - "status", - models.CharField( - choices=[ - ("PREPROCESSING", "Preprocessing"), - ("APPROVAL", "Approval"), - ("POSTPROCESSING", "Postprocessing"), - ], - default="PREPROCESSING", - max_length=30, - ), - ), - ("core", models.BooleanField()), - ("is_update", models.BooleanField()), - ], - ), - migrations.RemoveField( - model_name="workflowmeta", - name="id", - ), - migrations.RemoveField( - model_name="workflowstatus", - name="id", - ), - migrations.DeleteModel( - name="WorkflowData", - ), - migrations.DeleteModel( - name="WorkflowMeta", - ), - migrations.DeleteModel( - name="WorkflowStatus", - ), - ] diff --git a/backoffice/backoffice/workflows/migrations/0003_workflowticket.py b/backoffice/backoffice/workflows/migrations/0003_workflowticket.py deleted file mode 100644 index 8255454a65..0000000000 --- a/backoffice/backoffice/workflows/migrations/0003_workflowticket.py +++ /dev/null @@ -1,35 +0,0 @@ -# Generated by Django 4.2.6 on 2023-11-20 14:17 - -import django.db.models.deletion -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("workflows", "0002_workflow_remove_workflowmeta_id_and_more"), - ] - - operations = [ - migrations.CreateModel( - name="WorkflowTicket", - fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ("ticket_id", models.CharField(max_length=32)), - ( - "workflow_id", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - to="workflows.workflow", - ), - ), - ], - ), - ] diff --git a/backoffice/backoffice/workflows/migrations/0004_workflow_workflow_type.py b/backoffice/backoffice/workflows/migrations/0004_workflow_workflow_type.py deleted file mode 100644 index d60a7cd253..0000000000 --- a/backoffice/backoffice/workflows/migrations/0004_workflow_workflow_type.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 4.2.6 on 2023-11-20 14:27 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("workflows", "0003_workflowticket"), - ] - - operations = [ - migrations.AddField( - model_name="workflow", - name="workflow_type", - field=models.CharField( - choices=[ - ("HEP_CREATE", "HEP create"), - ("HEP_UPDATE", "HEP update"), - ("AUTHOR_CREATE", "Author create"), - ("AUTHOR_UPDATE", "Author update"), - ], - default="HEP_create", - max_length=30, - ), - ), - ] diff --git a/backoffice/backoffice/workflows/migrations/0005_workflowticket_ticket_type_alter_workflow_status.py b/backoffice/backoffice/workflows/migrations/0005_workflowticket_ticket_type_alter_workflow_status.py deleted file mode 100644 index 79dc03fcb7..0000000000 --- a/backoffice/backoffice/workflows/migrations/0005_workflowticket_ticket_type_alter_workflow_status.py +++ /dev/null @@ -1,38 +0,0 @@ -# Generated by Django 4.2.6 on 2023-12-07 14:57 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("workflows", "0004_workflow_workflow_type"), - ] - - operations = [ - migrations.AddField( - model_name="workflowticket", - name="ticket_type", - field=models.CharField( - choices=[ - ("author_create_curation", "Author create curation"), - ("author_create_user", "Author create user"), - ], - default="author_create_curation", - max_length=30, - ), - ), - migrations.AlterField( - model_name="workflow", - name="status", - field=models.CharField( - choices=[ - ("running", "Running"), - ("approval", "Waiting for approval"), - ("completed", "Completed"), - ("error", "Error"), - ], - default="running", - max_length=30, - ), - ), - ] diff --git a/backoffice/backoffice/workflows/migrations/0006_workflow__created_at_workflow__updated_at.py b/backoffice/backoffice/workflows/migrations/0006_workflow__created_at_workflow__updated_at.py deleted file mode 100644 index b472ffd8fd..0000000000 --- a/backoffice/backoffice/workflows/migrations/0006_workflow__created_at_workflow__updated_at.py +++ /dev/null @@ -1,26 +0,0 @@ -# Generated by Django 4.2.6 on 2024-06-03 06:25 - -import django.utils.timezone -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("workflows", "0005_workflowticket_ticket_type_alter_workflow_status"), - ] - - operations = [ - migrations.AddField( - model_name="workflow", - name="_created_at", - field=models.DateTimeField( - auto_now_add=True, default=django.utils.timezone.now - ), - preserve_default=False, - ), - migrations.AddField( - model_name="workflow", - name="_updated_at", - field=models.DateTimeField(auto_now=True), - ), - ] diff --git a/backoffice/backoffice/workflows/migrations/0007_alter_workflow_core_alter_workflow_is_update.py b/backoffice/backoffice/workflows/migrations/0007_alter_workflow_core_alter_workflow_is_update.py deleted file mode 100644 index 1f0673ae82..0000000000 --- a/backoffice/backoffice/workflows/migrations/0007_alter_workflow_core_alter_workflow_is_update.py +++ /dev/null @@ -1,22 +0,0 @@ -# Generated by Django 4.2.6 on 2024-06-20 09:07 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("workflows", "0006_workflow__created_at_workflow__updated_at"), - ] - - operations = [ - migrations.AlterField( - model_name="workflow", - name="core", - field=models.BooleanField(default=False), - ), - migrations.AlterField( - model_name="workflow", - name="is_update", - field=models.BooleanField(default=False), - ), - ] diff --git a/backoffice/backoffice/workflows/migrations/0008_alter_workflow_status_alter_workflow_workflow_type.py b/backoffice/backoffice/workflows/migrations/0008_alter_workflow_status_alter_workflow_workflow_type.py deleted file mode 100644 index e879dd0f55..0000000000 --- a/backoffice/backoffice/workflows/migrations/0008_alter_workflow_status_alter_workflow_workflow_type.py +++ /dev/null @@ -1,40 +0,0 @@ -# Generated by Django 4.2.6 on 2024-07-09 12:42 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("workflows", "0007_alter_workflow_core_alter_workflow_is_update"), - ] - - operations = [ - migrations.AlterField( - model_name="workflow", - name="status", - field=models.CharField( - choices=[ - ("running", "Running"), - ("approval", "Waiting for approva"), - ("completed", "Completed"), - ("error", "Error"), - ], - default="running", - max_length=30, - ), - ), - migrations.AlterField( - model_name="workflow", - name="workflow_type", - field=models.CharField( - choices=[ - ("HEP_CREATE", "HEP create"), - ("HEP_UPDATE", "HEP update"), - ("AUTHOR_CREATE", "Author create"), - ("AUTHOR_UPDATE", "Author update"), - ], - default="HEP_CREATE", - max_length=30, - ), - ), - ] diff --git a/backoffice/backoffice/workflows/migrations/0009_decision.py b/backoffice/backoffice/workflows/migrations/0009_decision.py deleted file mode 100644 index a33ca92456..0000000000 --- a/backoffice/backoffice/workflows/migrations/0009_decision.py +++ /dev/null @@ -1,58 +0,0 @@ -# Generated by Django 4.2.6 on 2024-08-15 12:25 - -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", "0008_alter_workflow_status_alter_workflow_workflow_type"), - ] - - operations = [ - migrations.CreateModel( - name="Decision", - fields=[ - ( - "id", - models.BigAutoField( - auto_created=True, - primary_key=True, - serialize=False, - verbose_name="ID", - ), - ), - ( - "action", - models.CharField( - choices=[ - ("accept", "author_create_approved_dag"), - ("reject", "author_create_rejected_dag"), - ("accept_curate", "author_create_approved_dag"), - ], - max_length=30, - ), - ), - ("_created_at", models.DateTimeField(auto_now_add=True)), - ("_updated_at", models.DateTimeField(auto_now=True)), - ( - "user", - models.ForeignKey( - db_column="email", - on_delete=django.db.models.deletion.CASCADE, - to=settings.AUTH_USER_MODEL, - to_field="email", - ), - ), - ( - "workflow", - models.ForeignKey( - on_delete=django.db.models.deletion.CASCADE, - to="workflows.workflow", - ), - ), - ], - ), - ] 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 deleted file mode 100644 index a9cefea0e9..0000000000 --- a/backoffice/backoffice/workflows/migrations/0010_alter_decision_workflow_and_more.py +++ /dev/null @@ -1,31 +0,0 @@ -# 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/migrations/0011_rename_workflow_id_workflowticket_workflow_and_more.py b/backoffice/backoffice/workflows/migrations/0011_rename_workflow_id_workflowticket_workflow_and_more.py deleted file mode 100644 index 4b89b71743..0000000000 --- a/backoffice/backoffice/workflows/migrations/0011_rename_workflow_id_workflowticket_workflow_and_more.py +++ /dev/null @@ -1,31 +0,0 @@ -# Generated by Django 4.2.6 on 2024-08-28 11:59 - -import django.utils.timezone -from django.db import migrations, models - - -class Migration(migrations.Migration): - dependencies = [ - ("workflows", "0010_alter_decision_workflow_and_more"), - ] - - operations = [ - migrations.RenameField( - model_name="workflowticket", - old_name="workflow_id", - new_name="workflow", - ), - migrations.AddField( - model_name="workflowticket", - name="_created_at", - field=models.DateTimeField( - auto_now_add=True, default=django.utils.timezone.now - ), - preserve_default=False, - ), - migrations.AddField( - model_name="workflowticket", - name="_updated_at", - field=models.DateTimeField(auto_now=True), - ), - ] diff --git a/backoffice/backoffice/workflows/migrations/__init__.py b/backoffice/backoffice/workflows/migrations/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/backoffice/config/api_router.py b/backoffice/config/api_router.py index b86606dbf1..fd25d873ca 100644 --- a/backoffice/config/api_router.py +++ b/backoffice/config/api_router.py @@ -1,9 +1,8 @@ from backoffice.users.api.views import UserViewSet -from backoffice.workflows.api.views import ( +from backoffice.authors.api.views import ( AuthorWorkflowViewSet, - DecisionViewSet, - WorkflowTicketViewSet, - WorkflowViewSet, + AuthorDecisionViewSet, + AuthorWorkflowTicketViewSet, ) from django.conf import settings from rest_framework.routers import DefaultRouter, SimpleRouter @@ -18,8 +17,12 @@ "workflows/authors", AuthorWorkflowViewSet, basename="workflows-authors" ), ) -router.register("workflows", WorkflowViewSet, basename="workflows") -(router.register("workflow-ticket", WorkflowTicketViewSet, basename="workflow-ticket"),) -router.register("decisions", DecisionViewSet, basename="decisions") +router.register("workflows", AuthorWorkflowViewSet, basename="workflows") +( + router.register( + "workflow-ticket", AuthorWorkflowTicketViewSet, basename="workflow-ticket" + ), +) +router.register("decisions", AuthorDecisionViewSet, basename="decisions") app_name = "api" urlpatterns = router.urls diff --git a/backoffice/config/search_router.py b/backoffice/config/search_router.py index ce6c4c2252..b7b40f4a37 100644 --- a/backoffice/config/search_router.py +++ b/backoffice/config/search_router.py @@ -1,4 +1,4 @@ -from backoffice.workflows.api.views import WorkflowDocumentView +from backoffice.authors.api.views import AuthorWorkflowDocumentView from django.conf import settings from rest_framework.routers import DefaultRouter, SimpleRouter @@ -6,7 +6,7 @@ # Workflow -router.register("workflows/search", WorkflowDocumentView, basename="workflow") +router.register("workflows/search", AuthorWorkflowDocumentView, basename="workflow") app_name = "search" urlpatterns = router.urls diff --git a/backoffice/config/settings/base.py b/backoffice/config/settings/base.py index ba06396d25..9f5cb02ddf 100644 --- a/backoffice/config/settings/base.py +++ b/backoffice/config/settings/base.py @@ -109,7 +109,7 @@ "django_json_widget", ] -LOCAL_APPS = ["backoffice.users", "backoffice.workflows", "backoffice.management"] +LOCAL_APPS = ["backoffice.users", "backoffice.authors", "backoffice.management"] # https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS @@ -389,7 +389,7 @@ # ------------------------------------------------------------------------------ # Name of the Opensearch index OPENSEARCH_INDEX_NAMES = { - "backoffice.workflows.documents": f'{env("OPENSEARCH_INDEX_PREFIX")}-workflows', + "backoffice.authors.documents": f'{env("OPENSEARCH_INDEX_PREFIX")}-workflows', } OPENSEARCH_DSL = { diff --git a/backoffice/config/settings/test.py b/backoffice/config/settings/test.py index 1474411033..a510df2de6 100644 --- a/backoffice/config/settings/test.py +++ b/backoffice/config/settings/test.py @@ -39,7 +39,7 @@ # ------------------------------------------------------------------------------ # Name of the Opensearch index OPENSEARCH_INDEX_NAMES = { - "backoffice.workflows.documents": "backoffice-backend-test-workflows", + "backoffice.authors.documents": "backoffice-backend-test-workflows", } # Force an index refresh with every save. OPENSEARCH_DSL_AUTO_REFRESH = True