From 775ec5fb78e4b309a00c13d7f3244a8e29a10357 Mon Sep 17 00:00:00 2001 From: Fabio Roberto Vitello <fabio.vitello@inaf.it> Date: Wed, 2 Dec 2020 21:21:10 +0100 Subject: [PATCH] TMSS-419: New scheduling_unit_flow/qa_scheduling_unit_task API scheduling_unit_flow/qa_scheduling_unit_task allows to navigate the workflow steps and to get the current status --- SAS/TMSS/src/tmss/settings.py | 3 ++- .../src/tmss/tmssapp/migrations/0001_initial.py | 2 +- SAS/TMSS/src/tmss/urls.py | 1 + SAS/TMSS/src/tmss/workflowapp/apps.py | 2 +- .../tmss/workflowapp/flows/schedulingunitflow.py | 2 +- .../tmss/workflowapp/migrations/0001_initial.py | 16 ++-------------- SAS/TMSS/src/tmss/workflowapp/models/__init__.py | 1 - .../workflowapp/models/schedulingunitflow.py | 4 +++- .../serializers/schedulingunitflow.py | 11 +++++++++-- .../workflowapp/viewsets/schedulingunitflow.py | 5 +++++ 10 files changed, 25 insertions(+), 22 deletions(-) diff --git a/SAS/TMSS/src/tmss/settings.py b/SAS/TMSS/src/tmss/settings.py index e8b60ccede3..762d4d99eaf 100644 --- a/SAS/TMSS/src/tmss/settings.py +++ b/SAS/TMSS/src/tmss/settings.py @@ -92,7 +92,8 @@ INSTALLED_APPS = [ 'drf_yasg', 'django_filters', 'material', - 'material.frontend'] + 'material.frontend' + ] MIDDLEWARE = [ 'django.middleware.gzip.GZipMiddleware', diff --git a/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py b/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py index 9cb552a539f..5534c996057 100644 --- a/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py +++ b/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.9 on 2020-11-30 08:59 +# Generated by Django 3.0.9 on 2020-12-02 20:16 from django.conf import settings import django.contrib.postgres.fields diff --git a/SAS/TMSS/src/tmss/urls.py b/SAS/TMSS/src/tmss/urls.py index 419387b6de0..253223e209b 100644 --- a/SAS/TMSS/src/tmss/urls.py +++ b/SAS/TMSS/src/tmss/urls.py @@ -234,6 +234,7 @@ if bool(os.environ.get('TMSS_ENABLE_VIEWFLOW', False)): viewflow_router.register('scheduling_unit_flow/qa_pi_verification', workflow_viewsets.PIVerificationViewSet, basename='qa_pi_verification') viewflow_router.register('scheduling_unit_flow/qa_decide_acceptance', workflow_viewsets.DecideAcceptanceViewSet, basename='qa_decide_acceptance') viewflow_router.register('scheduling_unit_flow/qa_scheduling_unit_process', workflow_viewsets.SchedulingUnitProcessViewSet, basename='qa_scheduling_unit_process') + viewflow_router.register('scheduling_unit_flow/qa_scheduling_unit_task', workflow_viewsets.SchedulingUnitTaskViewSet, basename='qa_scheduling_unit_task') viewflow_urlpatterns.extend(viewflow_router.urls) diff --git a/SAS/TMSS/src/tmss/workflowapp/apps.py b/SAS/TMSS/src/tmss/workflowapp/apps.py index 3ba8ab2cdb3..b4d7b07f0d0 100644 --- a/SAS/TMSS/src/tmss/workflowapp/apps.py +++ b/SAS/TMSS/src/tmss/workflowapp/apps.py @@ -4,5 +4,5 @@ from django.apps import AppConfig class WorkflowappConfig(AppConfig): - name = 'lofar.sas.tmss.tmss.workflowapp' + name = 'workflowapp' diff --git a/SAS/TMSS/src/tmss/workflowapp/flows/schedulingunitflow.py b/SAS/TMSS/src/tmss/workflowapp/flows/schedulingunitflow.py index 32a11808966..8bec6f43db2 100644 --- a/SAS/TMSS/src/tmss/workflowapp/flows/schedulingunitflow.py +++ b/SAS/TMSS/src/tmss/workflowapp/flows/schedulingunitflow.py @@ -66,6 +66,7 @@ class Condition(Signal): activation.prepare() if activation.flow_task.condition_check(activation, instance): activation.done() + def ready(self): """Resolve internal `this`-references. and subscribe to the signal.""" @@ -210,7 +211,6 @@ class SchedulingUnitFlow(Flow): return activation - def check_condition_scheduled(self, activation, instance): if instance is None: instance = activation.process.su diff --git a/SAS/TMSS/src/tmss/workflowapp/migrations/0001_initial.py b/SAS/TMSS/src/tmss/workflowapp/migrations/0001_initial.py index aa03e1a4d75..8119f3254e3 100644 --- a/SAS/TMSS/src/tmss/workflowapp/migrations/0001_initial.py +++ b/SAS/TMSS/src/tmss/workflowapp/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.9 on 2020-11-26 09:54 +# Generated by Django 3.0.9 on 2020-12-02 20:16 from django.db import migrations, models import django.db.models.deletion @@ -9,6 +9,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ + ('tmssapp', '0001_initial'), ('viewflow', '0008_jsonfield_and_artifact'), ] @@ -45,19 +46,6 @@ class Migration(migrations.Migration): ('operator_accept', models.BooleanField(default=False)), ], ), - migrations.CreateModel( - name='HelloWorldProcess', - fields=[ - ], - options={ - 'verbose_name': 'World Request', - 'verbose_name_plural': 'World Requests', - 'proxy': True, - 'indexes': [], - 'constraints': [], - }, - bases=('viewflow.process',), - ), migrations.CreateModel( name='SchedulingUnitProcess', fields=[ diff --git a/SAS/TMSS/src/tmss/workflowapp/models/__init__.py b/SAS/TMSS/src/tmss/workflowapp/models/__init__.py index a0ae3713747..bfdfbc84e07 100644 --- a/SAS/TMSS/src/tmss/workflowapp/models/__init__.py +++ b/SAS/TMSS/src/tmss/workflowapp/models/__init__.py @@ -1,2 +1 @@ -from .helloworldflow import * from .schedulingunitflow import * \ No newline at end of file diff --git a/SAS/TMSS/src/tmss/workflowapp/models/schedulingunitflow.py b/SAS/TMSS/src/tmss/workflowapp/models/schedulingunitflow.py index c883b4fc9a3..d33f462ed65 100644 --- a/SAS/TMSS/src/tmss/workflowapp/models/schedulingunitflow.py +++ b/SAS/TMSS/src/tmss/workflowapp/models/schedulingunitflow.py @@ -1,7 +1,9 @@ # Create your models here. from django.db.models import CharField, IntegerField,BooleanField, ForeignKey, CASCADE, Model,NullBooleanField -from viewflow.models import Process +from viewflow.models import Process, Task +from viewflow.fields import FlowReferenceField +from viewflow.compat import _ from lofar.sas.tmss.tmss.tmssapp.models import SchedulingUnitBlueprint diff --git a/SAS/TMSS/src/tmss/workflowapp/serializers/schedulingunitflow.py b/SAS/TMSS/src/tmss/workflowapp/serializers/schedulingunitflow.py index 884061c2241..86a87874a52 100644 --- a/SAS/TMSS/src/tmss/workflowapp/serializers/schedulingunitflow.py +++ b/SAS/TMSS/src/tmss/workflowapp/serializers/schedulingunitflow.py @@ -4,6 +4,8 @@ from lofar.sas.tmss.tmss.workflowapp import models from django.views import generic from django.forms.models import modelform_factory +from viewflow.models import Task + from .. import forms @@ -31,5 +33,10 @@ class DecideAcceptanceSerializer(ModelSerializer): class SchedulingUnitProcessSerializer(ModelSerializer): class Meta: - model = models.SchedulingUnitProcess - fields = '__all__' \ No newline at end of file + model = models.SchedulingUnitProcess + fields = ['su','active_task','qa_reporting_to','qa_reporting_sos','pi_verification','decide_acceptance','can_delete','results_accepted','created','finished'] + +class SchedulingUnitTaskSerializer(ModelSerializer): + class Meta: + model = Task + fields = '__all__' \ No newline at end of file diff --git a/SAS/TMSS/src/tmss/workflowapp/viewsets/schedulingunitflow.py b/SAS/TMSS/src/tmss/workflowapp/viewsets/schedulingunitflow.py index 530d4cb8f9c..acaa7459631 100644 --- a/SAS/TMSS/src/tmss/workflowapp/viewsets/schedulingunitflow.py +++ b/SAS/TMSS/src/tmss/workflowapp/viewsets/schedulingunitflow.py @@ -11,6 +11,7 @@ from viewflow.flow.views.utils import get_next_task_url from django.forms import CharField, CheckboxInput from django.forms.models import modelform_factory +from viewflow.models import Task from .. import forms, models, serializers @@ -36,6 +37,10 @@ class SchedulingUnitProcessViewSet(viewsets.ModelViewSet): queryset = models.SchedulingUnitProcess.objects.all() serializer_class = serializers.SchedulingUnitProcessSerializer +class SchedulingUnitTaskViewSet(viewsets.ModelViewSet): + queryset = Task.objects.all() + serializer_class = serializers.SchedulingUnitTaskSerializer + class QAReportingTOView(FlowMixin, generic.CreateView): template_name = 'qa_reporting.html' model = models.QAReportingTO -- GitLab