From 0ad30c0755da8f6ffc8bbbc08a45b537b95d2bf9 Mon Sep 17 00:00:00 2001
From: Fabio Roberto Vitello <fabio.vitello@inaf.it>
Date: Wed, 30 Sep 2020 11:47:26 +0200
Subject: [PATCH] TMSS-388: Created new django app for viewflow

Moved viewflow from tmssapp to the new workflowapp
---
 SAS/TMSS/src/tmss/CMakeLists.txt              |  1 +
 SAS/TMSS/src/tmss/settings.py                 |  1 +
 SAS/TMSS/src/tmss/tmssapp/CMakeLists.txt      |  2 -
 .../tmss/tmssapp/migrations/0001_initial.py   | 41 +--------------
 .../src/tmss/tmssapp/models/CMakeLists.txt    |  2 -
 SAS/TMSS/src/tmss/tmssapp/models/__init__.py  |  4 +-
 .../src/tmss/tmssapp/viewsets/CMakeLists.txt  |  2 -
 .../src/tmss/tmssapp/viewsets/__init__.py     |  3 +-
 SAS/TMSS/src/tmss/urls.py                     |  2 +-
 SAS/TMSS/src/tmss/workflowapp/CMakeLists.txt  | 19 +++++++
 .../__init__.py}                              |  0
 SAS/TMSS/src/tmss/workflowapp/admin.py        |  3 ++
 SAS/TMSS/src/tmss/workflowapp/apps.py         |  5 ++
 .../workflowapp/migrations/0001_initial.py    | 50 +++++++++++++++++++
 .../workflowapp/migrations/CMakeLists.txt     |  8 +++
 .../tmss/workflowapp/migrations/__init__.py   |  0
 SAS/TMSS/src/tmss/workflowapp/models.py       |  3 ++
 .../models}/CMakeLists.txt                    |  2 +-
 .../models}/__init__.py                       |  0
 .../models/helloworldflow.py                  |  0
 .../models/schedulingunitdemoflow.py          |  0
 SAS/TMSS/src/tmss/workflowapp/tests.py        |  3 ++
 SAS/TMSS/src/tmss/workflowapp/views.py        |  3 ++
 .../tmss/workflowapp/viewsets/CMakeLists.txt  | 11 ++++
 .../src/tmss/workflowapp/viewsets/__init__.py |  1 +
 .../workflowapp/viewsets/helloworldflow.py    |  0
 .../viewsets/schedulingunitdemoflow.py        |  0
 .../tmss/workflowapp/workflows/CMakeLists.txt | 11 ++++
 .../tmss/workflowapp/workflows/__init__.py    |  2 +
 .../workflows/helloworldflow.py               |  0
 .../workflows/schedulingunitdemoflow.py       |  0
 31 files changed, 126 insertions(+), 53 deletions(-)
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/CMakeLists.txt
 rename SAS/TMSS/src/tmss/{tmssapp/viewsets/helloworldflow.py => workflowapp/__init__.py} (100%)
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/admin.py
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/apps.py
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/migrations/0001_initial.py
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/migrations/CMakeLists.txt
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/migrations/__init__.py
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/models.py
 rename SAS/TMSS/src/tmss/{tmssapp/workflows => workflowapp/models}/CMakeLists.txt (71%)
 rename SAS/TMSS/src/tmss/{tmssapp/workflows => workflowapp/models}/__init__.py (100%)
 rename SAS/TMSS/src/tmss/{tmssapp => workflowapp}/models/helloworldflow.py (100%)
 rename SAS/TMSS/src/tmss/{tmssapp => workflowapp}/models/schedulingunitdemoflow.py (100%)
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/tests.py
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/views.py
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/viewsets/CMakeLists.txt
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/viewsets/__init__.py
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/viewsets/helloworldflow.py
 rename SAS/TMSS/src/tmss/{tmssapp => workflowapp}/viewsets/schedulingunitdemoflow.py (100%)
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/workflows/CMakeLists.txt
 create mode 100644 SAS/TMSS/src/tmss/workflowapp/workflows/__init__.py
 rename SAS/TMSS/src/tmss/{tmssapp => workflowapp}/workflows/helloworldflow.py (100%)
 rename SAS/TMSS/src/tmss/{tmssapp => workflowapp}/workflows/schedulingunitdemoflow.py (100%)

diff --git a/SAS/TMSS/src/tmss/CMakeLists.txt b/SAS/TMSS/src/tmss/CMakeLists.txt
index a38c2b149ed..3e7754777f2 100644
--- a/SAS/TMSS/src/tmss/CMakeLists.txt
+++ b/SAS/TMSS/src/tmss/CMakeLists.txt
@@ -13,3 +13,4 @@ python_install(${_py_files}
     DESTINATION lofar/sas/tmss/tmss)
 
 add_subdirectory(tmssapp)
+add_subdirectory(workflowapp)
diff --git a/SAS/TMSS/src/tmss/settings.py b/SAS/TMSS/src/tmss/settings.py
index 3fcb6ea5e99..5e5d8e1e11e 100644
--- a/SAS/TMSS/src/tmss/settings.py
+++ b/SAS/TMSS/src/tmss/settings.py
@@ -116,6 +116,7 @@ INSTALLED_APPS = [
     'jsoneditor',
     'drf_yasg',
     'django_filters',
+    'lofar.sas.tmss.tmss.workflowapp',
     'material',
     'material.frontend',
     'viewflow',
diff --git a/SAS/TMSS/src/tmss/tmssapp/CMakeLists.txt b/SAS/TMSS/src/tmss/tmssapp/CMakeLists.txt
index e24af6998d0..58c545f7ed4 100644
--- a/SAS/TMSS/src/tmss/tmssapp/CMakeLists.txt
+++ b/SAS/TMSS/src/tmss/tmssapp/CMakeLists.txt
@@ -23,5 +23,3 @@ add_subdirectory(serializers)
 add_subdirectory(viewsets)
 add_subdirectory(adapters)
 add_subdirectory(schemas)
-add_subdirectory(workflows)
-
diff --git a/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py b/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py
index daa63f93694..45b53b6b1f1 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-09-24 15:47
+# Generated by Django 3.0.9 on 2020-09-30 09:15
 
 from django.conf import settings
 import django.contrib.postgres.fields
@@ -14,7 +14,6 @@ class Migration(migrations.Migration):
 
     dependencies = [
         migrations.swappable_dependency(settings.AUTH_USER_MODEL),
-        ('viewflow', '0008_jsonfield_and_artifact'),
     ]
 
     operations = [
@@ -492,26 +491,6 @@ class Migration(migrations.Migration):
                 'abstract': False,
             },
         ),
-        migrations.CreateModel(
-            name='SchedulingUnitDemo',
-            fields=[
-                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
-                ('name', models.CharField(max_length=50)),
-                ('state', models.IntegerField()),
-            ],
-        ),
-        migrations.CreateModel(
-            name='SchedulingUnitDemoProcess',
-            fields=[
-                ('process_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='viewflow.Process')),
-                ('text', models.CharField(max_length=150)),
-                ('approved', models.BooleanField(default=False)),
-            ],
-            options={
-                'abstract': False,
-            },
-            bases=('viewflow.process',),
-        ),
         migrations.CreateModel(
             name='SchedulingUnitDraft',
             fields=[
@@ -764,19 +743,6 @@ class Migration(migrations.Migration):
                 'abstract': 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='Setting',
             fields=[
@@ -1093,11 +1059,6 @@ class Migration(migrations.Migration):
             name='scheduling_set',
             field=models.ForeignKey(help_text='Set to which this scheduling unit draft belongs.', on_delete=django.db.models.deletion.CASCADE, related_name='scheduling_unit_drafts', to='tmssapp.SchedulingSet'),
         ),
-        migrations.AddField(
-            model_name='schedulingunitdemoprocess',
-            name='su',
-            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='tmssapp.SchedulingUnitDemo'),
-        ),
         migrations.AddField(
             model_name='schedulingunitblueprint',
             name='draft',
diff --git a/SAS/TMSS/src/tmss/tmssapp/models/CMakeLists.txt b/SAS/TMSS/src/tmss/tmssapp/models/CMakeLists.txt
index 2ac64b115ec..7598bc12c79 100644
--- a/SAS/TMSS/src/tmss/tmssapp/models/CMakeLists.txt
+++ b/SAS/TMSS/src/tmss/tmssapp/models/CMakeLists.txt
@@ -5,8 +5,6 @@ set(_py_files
     __init__.py
     specification.py
     scheduling.py
-    helloworldflow.py
-    schedulingunitdemoflow.py
     )
 
 python_install(${_py_files}
diff --git a/SAS/TMSS/src/tmss/tmssapp/models/__init__.py b/SAS/TMSS/src/tmss/tmssapp/models/__init__.py
index be7a174d740..93f3c7e6d54 100644
--- a/SAS/TMSS/src/tmss/tmssapp/models/__init__.py
+++ b/SAS/TMSS/src/tmss/tmssapp/models/__init__.py
@@ -1,4 +1,2 @@
 from .specification import *
-from .scheduling import *
-from .helloworldflow import *
-from .schedulingunitdemoflow import *
\ No newline at end of file
+from .scheduling import *
\ No newline at end of file
diff --git a/SAS/TMSS/src/tmss/tmssapp/viewsets/CMakeLists.txt b/SAS/TMSS/src/tmss/tmssapp/viewsets/CMakeLists.txt
index 445e0bbe467..fc0325a5235 100644
--- a/SAS/TMSS/src/tmss/tmssapp/viewsets/CMakeLists.txt
+++ b/SAS/TMSS/src/tmss/tmssapp/viewsets/CMakeLists.txt
@@ -6,8 +6,6 @@ set(_py_files
     lofar_viewset.py
     specification.py
     scheduling.py
-    helloworldflow.py
-    schedulingunitdemoflow.py
     )
 
 python_install(${_py_files}
diff --git a/SAS/TMSS/src/tmss/tmssapp/viewsets/__init__.py b/SAS/TMSS/src/tmss/tmssapp/viewsets/__init__.py
index 882458975ee..93f3c7e6d54 100644
--- a/SAS/TMSS/src/tmss/tmssapp/viewsets/__init__.py
+++ b/SAS/TMSS/src/tmss/tmssapp/viewsets/__init__.py
@@ -1,3 +1,2 @@
 from .specification import *
-from .scheduling import *
-from .schedulingunitdemoflow import *
\ No newline at end of file
+from .scheduling import *
\ No newline at end of file
diff --git a/SAS/TMSS/src/tmss/urls.py b/SAS/TMSS/src/tmss/urls.py
index 37d9d081a3a..af3411b8689 100644
--- a/SAS/TMSS/src/tmss/urls.py
+++ b/SAS/TMSS/src/tmss/urls.py
@@ -23,7 +23,7 @@ from django.views.generic.base import TemplateView, RedirectView
 
 from collections import OrderedDict
 from rest_framework import routers, permissions
-from .tmssapp import viewsets, models, serializers, views, workflows
+from .tmssapp import viewsets, models, serializers, views
 from rest_framework.documentation import include_docs_urls
 from drf_yasg.views import get_schema_view
 from drf_yasg import openapi
diff --git a/SAS/TMSS/src/tmss/workflowapp/CMakeLists.txt b/SAS/TMSS/src/tmss/workflowapp/CMakeLists.txt
new file mode 100644
index 00000000000..1c8dc797642
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/CMakeLists.txt
@@ -0,0 +1,19 @@
+
+include(PythonInstall)
+
+set(_py_files
+    __init__.py
+    admin.py
+    apps.py
+    )
+
+python_install(${_py_files}
+    DESTINATION lofar/sas/tmss/tmss/workflowapp)
+
+
+
+add_subdirectory(migrations)
+add_subdirectory(models)
+add_subdirectory(viewsets)
+add_subdirectory(workflows)
+
diff --git a/SAS/TMSS/src/tmss/tmssapp/viewsets/helloworldflow.py b/SAS/TMSS/src/tmss/workflowapp/__init__.py
similarity index 100%
rename from SAS/TMSS/src/tmss/tmssapp/viewsets/helloworldflow.py
rename to SAS/TMSS/src/tmss/workflowapp/__init__.py
diff --git a/SAS/TMSS/src/tmss/workflowapp/admin.py b/SAS/TMSS/src/tmss/workflowapp/admin.py
new file mode 100644
index 00000000000..8c38f3f3dad
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/admin.py
@@ -0,0 +1,3 @@
+from django.contrib import admin
+
+# Register your models here.
diff --git a/SAS/TMSS/src/tmss/workflowapp/apps.py b/SAS/TMSS/src/tmss/workflowapp/apps.py
new file mode 100644
index 00000000000..7a61bbed619
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/apps.py
@@ -0,0 +1,5 @@
+from django.apps import AppConfig
+
+
+class WorkfowappConfig(AppConfig):
+    name = 'workfowapp'
diff --git a/SAS/TMSS/src/tmss/workflowapp/migrations/0001_initial.py b/SAS/TMSS/src/tmss/workflowapp/migrations/0001_initial.py
new file mode 100644
index 00000000000..102edfd62a8
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/migrations/0001_initial.py
@@ -0,0 +1,50 @@
+# Generated by Django 3.0.9 on 2020-09-30 09:15
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    initial = True
+
+    dependencies = [
+        ('viewflow', '0008_jsonfield_and_artifact'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='SchedulingUnitDemo',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('name', models.CharField(max_length=50)),
+                ('state', models.IntegerField()),
+            ],
+        ),
+        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='SchedulingUnitDemoProcess',
+            fields=[
+                ('process_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='viewflow.Process')),
+                ('text', models.CharField(max_length=150)),
+                ('approved', models.BooleanField(default=False)),
+                ('su', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='workflowapp.SchedulingUnitDemo')),
+            ],
+            options={
+                'abstract': False,
+            },
+            bases=('viewflow.process',),
+        ),
+    ]
diff --git a/SAS/TMSS/src/tmss/workflowapp/migrations/CMakeLists.txt b/SAS/TMSS/src/tmss/workflowapp/migrations/CMakeLists.txt
new file mode 100644
index 00000000000..158ea794644
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/migrations/CMakeLists.txt
@@ -0,0 +1,8 @@
+
+include(PythonInstall)
+
+
+FILE(GLOB _py_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.py)
+
+python_install(${_py_files}
+    DESTINATION lofar/sas/tmss/tmss/workflowapp/migrations)
\ No newline at end of file
diff --git a/SAS/TMSS/src/tmss/workflowapp/migrations/__init__.py b/SAS/TMSS/src/tmss/workflowapp/migrations/__init__.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/SAS/TMSS/src/tmss/workflowapp/models.py b/SAS/TMSS/src/tmss/workflowapp/models.py
new file mode 100644
index 00000000000..71a83623907
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/models.py
@@ -0,0 +1,3 @@
+from django.db import models
+
+# Create your models here.
diff --git a/SAS/TMSS/src/tmss/tmssapp/workflows/CMakeLists.txt b/SAS/TMSS/src/tmss/workflowapp/models/CMakeLists.txt
similarity index 71%
rename from SAS/TMSS/src/tmss/tmssapp/workflows/CMakeLists.txt
rename to SAS/TMSS/src/tmss/workflowapp/models/CMakeLists.txt
index 474aada3304..1c94f0a15d5 100644
--- a/SAS/TMSS/src/tmss/tmssapp/workflows/CMakeLists.txt
+++ b/SAS/TMSS/src/tmss/workflowapp/models/CMakeLists.txt
@@ -8,4 +8,4 @@ set(_py_files
     )
 
 python_install(${_py_files}
-    DESTINATION lofar/sas/tmss/tmss/tmssapp/workflows)
+    DESTINATION lofar/sas/tmss/tmss/workflowapp/models)
diff --git a/SAS/TMSS/src/tmss/tmssapp/workflows/__init__.py b/SAS/TMSS/src/tmss/workflowapp/models/__init__.py
similarity index 100%
rename from SAS/TMSS/src/tmss/tmssapp/workflows/__init__.py
rename to SAS/TMSS/src/tmss/workflowapp/models/__init__.py
diff --git a/SAS/TMSS/src/tmss/tmssapp/models/helloworldflow.py b/SAS/TMSS/src/tmss/workflowapp/models/helloworldflow.py
similarity index 100%
rename from SAS/TMSS/src/tmss/tmssapp/models/helloworldflow.py
rename to SAS/TMSS/src/tmss/workflowapp/models/helloworldflow.py
diff --git a/SAS/TMSS/src/tmss/tmssapp/models/schedulingunitdemoflow.py b/SAS/TMSS/src/tmss/workflowapp/models/schedulingunitdemoflow.py
similarity index 100%
rename from SAS/TMSS/src/tmss/tmssapp/models/schedulingunitdemoflow.py
rename to SAS/TMSS/src/tmss/workflowapp/models/schedulingunitdemoflow.py
diff --git a/SAS/TMSS/src/tmss/workflowapp/tests.py b/SAS/TMSS/src/tmss/workflowapp/tests.py
new file mode 100644
index 00000000000..7ce503c2dd9
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/tests.py
@@ -0,0 +1,3 @@
+from django.test import TestCase
+
+# Create your tests here.
diff --git a/SAS/TMSS/src/tmss/workflowapp/views.py b/SAS/TMSS/src/tmss/workflowapp/views.py
new file mode 100644
index 00000000000..91ea44a218f
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/views.py
@@ -0,0 +1,3 @@
+from django.shortcuts import render
+
+# Create your views here.
diff --git a/SAS/TMSS/src/tmss/workflowapp/viewsets/CMakeLists.txt b/SAS/TMSS/src/tmss/workflowapp/viewsets/CMakeLists.txt
new file mode 100644
index 00000000000..fb8816b9690
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/viewsets/CMakeLists.txt
@@ -0,0 +1,11 @@
+
+include(PythonInstall)
+
+set(_py_files
+    __init__.py
+    helloworldflow.py
+    schedulingunitdemoflow.py
+    )
+
+python_install(${_py_files}
+    DESTINATION lofar/sas/tmss/tmss/workflowapp/viewsets)
diff --git a/SAS/TMSS/src/tmss/workflowapp/viewsets/__init__.py b/SAS/TMSS/src/tmss/workflowapp/viewsets/__init__.py
new file mode 100644
index 00000000000..b77c70aeb95
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/viewsets/__init__.py
@@ -0,0 +1 @@
+from .schedulingunitdemoflow import *
\ No newline at end of file
diff --git a/SAS/TMSS/src/tmss/workflowapp/viewsets/helloworldflow.py b/SAS/TMSS/src/tmss/workflowapp/viewsets/helloworldflow.py
new file mode 100644
index 00000000000..e69de29bb2d
diff --git a/SAS/TMSS/src/tmss/tmssapp/viewsets/schedulingunitdemoflow.py b/SAS/TMSS/src/tmss/workflowapp/viewsets/schedulingunitdemoflow.py
similarity index 100%
rename from SAS/TMSS/src/tmss/tmssapp/viewsets/schedulingunitdemoflow.py
rename to SAS/TMSS/src/tmss/workflowapp/viewsets/schedulingunitdemoflow.py
diff --git a/SAS/TMSS/src/tmss/workflowapp/workflows/CMakeLists.txt b/SAS/TMSS/src/tmss/workflowapp/workflows/CMakeLists.txt
new file mode 100644
index 00000000000..f52cef52d6e
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/workflows/CMakeLists.txt
@@ -0,0 +1,11 @@
+
+include(PythonInstall)
+
+set(_py_files
+    __init__.py
+    helloworldflow.py
+    schedulingunitdemoflow.py
+    )
+
+python_install(${_py_files}
+    DESTINATION lofar/sas/tmss/tmss/workflowapp/workflows)
diff --git a/SAS/TMSS/src/tmss/workflowapp/workflows/__init__.py b/SAS/TMSS/src/tmss/workflowapp/workflows/__init__.py
new file mode 100644
index 00000000000..45516795a25
--- /dev/null
+++ b/SAS/TMSS/src/tmss/workflowapp/workflows/__init__.py
@@ -0,0 +1,2 @@
+from .helloworldflow import *
+from .schedulingunitdemoflow import *
\ No newline at end of file
diff --git a/SAS/TMSS/src/tmss/tmssapp/workflows/helloworldflow.py b/SAS/TMSS/src/tmss/workflowapp/workflows/helloworldflow.py
similarity index 100%
rename from SAS/TMSS/src/tmss/tmssapp/workflows/helloworldflow.py
rename to SAS/TMSS/src/tmss/workflowapp/workflows/helloworldflow.py
diff --git a/SAS/TMSS/src/tmss/tmssapp/workflows/schedulingunitdemoflow.py b/SAS/TMSS/src/tmss/workflowapp/workflows/schedulingunitdemoflow.py
similarity index 100%
rename from SAS/TMSS/src/tmss/tmssapp/workflows/schedulingunitdemoflow.py
rename to SAS/TMSS/src/tmss/workflowapp/workflows/schedulingunitdemoflow.py
-- 
GitLab