diff --git a/rodan/__init__.py b/rodan/__init__.py index 73c13e7f3..bbbeb87b0 100644 --- a/rodan/__init__.py +++ b/rodan/__init__.py @@ -17,5 +17,5 @@ # Get version: import rodan; rodan.__version__ # Version numbers also appear in the API. __title__ = "Rodan" -__version__ = "1.2.0" +__version__ = "1.3.0" __copyright__ = "Copyright 2011-2020 Distributed Digital Music Archives & Libraries Lab" diff --git a/rodan/migrations/0023_auto_20200915_1923.py b/rodan/migrations/0023_auto_20200915_1923.py new file mode 100644 index 000000000..89a60e986 --- /dev/null +++ b/rodan/migrations/0023_auto_20200915_1923.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2020-09-15 23:23 +from __future__ import unicode_literals + +from django.db import migrations +import jsonfield.fields + + +def forwards_func(apps, schema_editor): + """ + Auto-populate appearance data from coordinate data in coordinate set + """ + db_alias = schema_editor.connection.alias + + wfj = apps.get_model("rodan", "WorkflowJob") + wfj_cs = apps.get_model("rodan", "WorkflowJobCoordinateSet") + wfjg = apps.get_model("rodan", "WorkflowJobGroup") + wfjg_cs = apps.get_model("rodan", "WorkflowJobGroupCoordinateSet") + + # Django 2.2 has bulk_update, 1.11.29 does not. + for i in wfj_cs.objects.using(db_alias): + w = wfj.objects.filter(uuid=i.workflow_job.uuid).update(appearance=i.data) + for i in wfjg_cs.objects.using(db_alias): + w = wfjg.objects.filter(uuid=i.workflow_job_group.uuid).update(appearance=i.data) + + +class Migration(migrations.Migration): + + dependencies = [ + ('rodan', '0022_auto_20200817_1511'), + ] + + operations = [ + migrations.AddField( + model_name='workflowjob', + name='appearance', + field=jsonfield.fields.JSONField(blank=True, null=True), + ), + migrations.AddField( + model_name='workflowjobgroup', + name='appearance', + field=jsonfield.fields.JSONField(blank=True, null=True), + ), + migrations.RunPython(forwards_func), + migrations.AlterField( + model_name='workflowjob', + name='appearance', + field=jsonfield.fields.JSONField(default={b'x': 0.5, b'y': 0.5}), + preserve_default=True, + ), + migrations.AlterField( + model_name='workflowjobgroup', + name='appearance', + field=jsonfield.fields.JSONField(default={b'x': 0.5, b'y': 0.5}), + preserve_default=True, + ), + migrations.DeleteModel( + name='WorkflowJobCoordinateSet', + ), + migrations.DeleteModel( + name='WorkflowJobGroupCoordinateSet', + ), + ] diff --git a/rodan/models/__init__.py b/rodan/models/__init__.py index 7f6cb220e..eed3f814f 100644 --- a/rodan/models/__init__.py +++ b/rodan/models/__init__.py @@ -41,8 +41,6 @@ from rodan.models.resourcetype import ResourceType from rodan.models.connection import Connection from rodan.models.tempauthtoken import Tempauthtoken -from rodan.models.workflowjobcoordinateset import WorkflowJobCoordinateSet -from rodan.models.workflowjobgroupcoordinateset import WorkflowJobGroupCoordinateSet if sys.version_info.major == 2: @@ -351,8 +349,6 @@ def assign_perms_project(sender, instance, created, raw, using, update_fields, * @receiver(post_save, sender=WorkflowJobGroup) @receiver(post_save, sender=InputPort) @receiver(post_save, sender=OutputPort) -@receiver(post_save, sender=WorkflowJobCoordinateSet) -@receiver(post_save, sender=WorkflowJobGroupCoordinateSet) @receiver(post_save, sender=Connection) @receiver(post_save, sender=RunJob) @receiver(post_save, sender=ResultsPackage) @@ -367,10 +363,10 @@ def assign_perms_others(sender, instance, created, raw, using, update_fields, ** project = instance.project elif sender in (WorkflowJob, WorkflowJobGroup): project = instance.workflow.project - elif sender in (InputPort, OutputPort, WorkflowJobCoordinateSet): + elif sender in (InputPort, OutputPort): # WorkflowJobCoordinateSet project = instance.workflow_job.workflow.project - elif sender in (WorkflowJobGroupCoordinateSet, ): - project = instance.workflow_job_group.workflow.project + # elif sender in (WorkflowJobGroupCoordinateSet, ): + # project = instance.workflow_job_group.workflow.project elif sender in (Connection, ): project = instance.input_port.workflow_job.workflow.project elif sender in (RunJob, ResultsPackage): diff --git a/rodan/models/workflowjob.py b/rodan/models/workflowjob.py index f8ce9431b..2f378edd2 100644 --- a/rodan/models/workflowjob.py +++ b/rodan/models/workflowjob.py @@ -22,6 +22,12 @@ class WorkflowJob(models.Model): - `name` -- user-defined name. Default: the same as `job_name`. - `group` -- a nullable reference to the `WorkflowGroup` object. + - `appearance` -- a JSON field including: + `x` -- coordinate of the center position (% of the canvas size); + `y` -- `y` coordinate of the center position (% of the canvas size); + `width` -- relative width regarding the canvas size; + `height` -- relative height regarding the canvas size; + `color` (optional) -- CSS color code. **Properties** @@ -65,6 +71,12 @@ class Meta: created = models.DateTimeField(auto_now_add=True, db_index=True) updated = models.DateTimeField(auto_now=True, db_index=True) + # OneToOneField continuously errors and asks for unique=True when it is already present. + # For this reason, a ForeignKey is still used. + appearance = JSONField( + default={"x": 0.5, "y": 0.5}, + ) + def save(self, *args, **kwargs): if not self.name: self.name = self.job_name.split(".")[-1] diff --git a/rodan/models/workflowjobcoordinateset.py b/rodan/models/workflowjobcoordinateset.py deleted file mode 100644 index 6ba803825..000000000 --- a/rodan/models/workflowjobcoordinateset.py +++ /dev/null @@ -1,47 +0,0 @@ -from django.db import models -from jsonfield import JSONField -import uuid - - -class WorkflowJobCoordinateSet(models.Model): - """ - A `WorkflowJobCoordinateSet` contains the x and y coordinates of the center - position of a `WorkflowJob` for a general or particular user agent. - - **Fields** - - - `uuid` - - `workflow_job` -- a reference to the `WorkflowJob`. - - `data` -- a JSON field including: - `x` -- coordinate of the center position (% of the canvas size); - `y` -- `y` coordinate of the center position (% of the canvas size); - `width` -- relative width regarding the canvas size; - `height` -- relative height regarding the canvas size; - `color` (optional) -- CSS color code. - - `user_agent` -- (optional) the name of user agent. - - `created` - - `updated` - """ - - class Meta: - app_label = "rodan" - unique_together = ("user_agent", "workflow_job") - permissions = ( - ("view_workflowjobcoordinateset", "View WorkflowJobCoordinateSet"), - ) - - uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4) - workflow_job = models.ForeignKey( - "rodan.WorkflowJob", - related_name="workflow_job_coordinate_sets", - on_delete=models.CASCADE, - db_index=True, - ) - data = JSONField(default={}, blank=True, null=True) - user_agent = models.CharField(max_length=255, blank=True, null=True, db_index=True) - - created = models.DateTimeField(auto_now_add=True, db_index=True) - updated = models.DateTimeField(auto_now=True, db_index=True) - - def __unicode__(self): - return u"".format(str(self.uuid)) diff --git a/rodan/models/workflowjobgroup.py b/rodan/models/workflowjobgroup.py index 0b21ad5eb..bf8076fd5 100644 --- a/rodan/models/workflowjobgroup.py +++ b/rodan/models/workflowjobgroup.py @@ -1,5 +1,6 @@ -from django.db import models import uuid +from django.db import models +from jsonfield import JSONField class WorkflowJobGroup(models.Model): @@ -14,6 +15,12 @@ class WorkflowJobGroup(models.Model): - `workflow` -- the `Workflow` that it belongs to. - `origin` -- a nullable reference to the `Workflow` indicating where it comes from. + - `appearance` -- a JSON field including: + `x` -- coordinate of the center position (% of the canvas size); + `y` -- `y` coordinate of the center position (% of the canvas size); + `width` -- relative width regarding the canvas size; + `height` -- relative height regarding the canvas size; + `color` (optional) -- CSS color code. - `created` - `updated` @@ -43,6 +50,9 @@ class Meta: created = models.DateTimeField(auto_now_add=True, db_index=True) updated = models.DateTimeField(auto_now=True, db_index=True) + appearance = JSONField( + default={"x": 0.5, "y": 0.5}, + ) def __unicode__(self): return u"".format(str(self.uuid)) diff --git a/rodan/models/workflowjobgroupcoordinateset.py b/rodan/models/workflowjobgroupcoordinateset.py deleted file mode 100644 index d4683d2e3..000000000 --- a/rodan/models/workflowjobgroupcoordinateset.py +++ /dev/null @@ -1,50 +0,0 @@ -from django.db import models -from jsonfield import JSONField -import uuid - - -class WorkflowJobGroupCoordinateSet(models.Model): - """ - A `WorkflowJobGroupCoordinateSet` contains the x and y coordinates of the center - position of a `WorkflowJobGroup` for a general or particular user agent. - - **Fields** - - - `uuid` - - `workflow_job_group` -- a reference to the `WorkflowJobGroup`. - - `data` -- a JSON field including: - `x` -- coordinate of the center position (% of the canvas size); - `y` -- `y` coordinate of the center position (% of the canvas size); - `width` -- relative width regarding the canvas size; - `height` -- relative height regarding the canvas size; - `color` (optional) -- CSS color code. - - `user_agent` -- (optional) the name of user agent. - - `created` - - `updated` - """ - - class Meta: - app_label = "rodan" - unique_together = ("user_agent", "workflow_job_group") - permissions = ( - ( - "view_workflowjobgroupcoordinateset", - "View WorkflowJobGroupCoordinateSet", - ), - ) - - uuid = models.UUIDField(primary_key=True, editable=False, default=uuid.uuid4) - workflow_job_group = models.ForeignKey( - "rodan.WorkflowJobGroup", - related_name="workflow_job_group_coordinate_sets", - on_delete=models.CASCADE, - db_index=True, - ) - data = JSONField(default={}, blank=True, null=True) - user_agent = models.CharField(max_length=255, blank=True, null=True, db_index=True) - - created = models.DateTimeField(auto_now_add=True, db_index=True) - updated = models.DateTimeField(auto_now=True, db_index=True) - - def __unicode__(self): - return u"".format(str(self.uuid)) diff --git a/rodan/serializers/workflow.py b/rodan/serializers/workflow.py index 66e10b3a5..47a72fdb6 100644 --- a/rodan/serializers/workflow.py +++ b/rodan/serializers/workflow.py @@ -529,4 +529,218 @@ def load(self, serialized, project_or_workflow, **k): return loaded_wfjs -version_map = {0.1: RodanWorkflowSerializationFormat_v_0_1()} +class RodanWorkflowSerializationFormat_v_0_2(RodanWorkflowSerializationFormat_v_0_1): + """ + Same as 0.1 with the addition of the appearance field + + # BUG: Fix group job import in next version of serialization format. + """ + __version__ = 0.2 + + schema = { + "type": "object", + "required": [ + "__version__", + "name", + "description", + "workflow_jobs", + "connections", + ], + "properties": { + "__version__": {"type": "number"}, + "name": {"type": "string"}, + "description": {"type": "string"}, + "workflow_jobs": { + "type": "array", + "items": { + "type": "object", + "required": [ + "input_ports", + "output_ports", + "job_name", + "job_settings", + ], + "properties": { + "input_ports": { + "type": "array", + "items": { + "type": "object", + "required": ["type", "id", "label"], + "properties": { + "type": {"type": "string"}, + "id": {"type": "number"}, + "label": {"type": "string"}, + }, + }, + "uniqueItems": True, + }, + "output_ports": { + "type": "array", + "items": { + "type": "object", + "required": ["type", "id", "label"], + "properties": { + "type": {"type": "string"}, + "id": {"type": "number"}, + "label": {"type": "string"}, + }, + }, + "uniqueItems": True, + }, + "job_name": {"type": "string"}, + "job_settings": {"type": "object"}, + "appearance": {"type": "object"}, + }, + }, + "uniqueItems": True, + }, + "connections": { + "type": "array", + "items": { + "type": "object", + "required": ["input_port", "output_port"], + "properties": { + "input_port": {"type": "number"}, + "output_port": {"type": "number"}, + }, + "uniqueItems": True, + }, + }, + }, + } + + def dump(self, wf_or_wfjgroup): + if isinstance(wf_or_wfjgroup, Workflow): + wf = wf_or_wfjgroup + wfjgroup = None + name = wf.name + description = wf.description or "" + elif isinstance(wf_or_wfjgroup, WorkflowJobGroup): + wfjgroup = wf_or_wfjgroup + wf = wfjgroup.workflow + name = wfjgroup.name + description = wfjgroup.description or "" + else: + raise TypeError("dump(wf_or_wfjgroup) receives a wrong type of argument.") + + rep = { + "__version__": self.__version__, + "name": name, + "description": description, + "workflow_jobs": [], + "connections": [], + } + + ip_map = {} + op_map = {} + ids = itertools.count(start=1, step=1) + + wfj_queryset = ( + wf.workflow_jobs.all() if wfjgroup is None else wfjgroup.workflow_jobs.all() + ) + for wfj in wfj_queryset: + rep_wfj = { + "job_name": wfj.job.name, + "job_settings": wfj.job_settings, + "input_ports": [], + "output_ports": [], + "appearance": wfj.appearance, + } + + for ip in wfj.input_ports.all(): + ip_map[ip.uuid.hex] = ids.next() + rep_ip = { + "label": ip.label, + "type": ip.input_port_type.name, + "id": ip_map[ip.uuid.hex], + } + rep_wfj["input_ports"].append(rep_ip) + + for op in wfj.output_ports.all(): + op_map[op.uuid.hex] = ids.next() + rep_op = { + "label": op.label, + "type": op.output_port_type.name, + "id": op_map[op.uuid.hex], + } + rep_wfj["output_ports"].append(rep_op) + rep["workflow_jobs"].append(rep_wfj) + + if wfjgroup is None: + conn_queryset = Connection.objects.filter( + input_port__workflow_job__workflow=wf + ) + else: + wfj_pks = list(wfj_queryset.values_list("pk", flat=True)) + conn_queryset = Connection.objects.filter( + input_port__workflow_job__in=wfj_pks, + output_port__workflow_job__in=wfj_pks, + ) + for conn in conn_queryset: + rep_conn = { + "output_port": op_map[conn.output_port.uuid.hex], + "input_port": ip_map[conn.input_port.uuid.hex], + } + rep["connections"].append(rep_conn) + + return rep + + def load(self, serialized, project_or_workflow, **k): + if isinstance(project_or_workflow, Project): + wf = Workflow.objects.create( + name=serialized["name"], + project=project_or_workflow, + description=serialized["description"], + creator=k.get("creator"), + valid=False, + ) + loaded_wfjs = [] + elif isinstance(project_or_workflow, Workflow): + wf = project_or_workflow + loaded_wfjs = [] + else: + raise TypeError( + "load(serialized, project_or_workflow, **k) receives a wrong type of argument." + ) + ip_map = {} + op_map = {} + + for wfj_s in serialized["workflow_jobs"]: + j = Job.objects.get(name=wfj_s["job_name"]) + wfj = WorkflowJob.objects.create( + workflow=wf, + job=j, + job_settings=wfj_s["job_settings"], + appearance=wfj_s["appearance"] + ) + for ip_s in wfj_s["input_ports"]: + ip = InputPort.objects.create( + workflow_job=wfj, + input_port_type=j.input_port_types.get(name=ip_s["type"]), + label=ip_s.get("label"), + ) + ip_map[ip_s["id"]] = ip + for op_s in wfj_s["output_ports"]: + op = OutputPort.objects.create( + workflow_job=wfj, + output_port_type=j.output_port_types.get(name=op_s["type"]), + label=op_s.get("label"), + ) + op_map[op_s["id"]] = op + loaded_wfjs.append(wfj) + for conn_s in serialized["connections"]: + conn = Connection.objects.create( # noqa + output_port=op_map[conn_s["output_port"]], + input_port=ip_map[conn_s["input_port"]], + ) + + if isinstance(project_or_workflow, Project): + return wf + elif isinstance(project_or_workflow, Workflow): + return loaded_wfjs + + +version_map = { + 0.1: RodanWorkflowSerializationFormat_v_0_1(), + 0.2: RodanWorkflowSerializationFormat_v_0_2(), +} diff --git a/rodan/serializers/workflowjob.py b/rodan/serializers/workflowjob.py index 1e3f809a3..1c61bdcf0 100644 --- a/rodan/serializers/workflowjob.py +++ b/rodan/serializers/workflowjob.py @@ -10,6 +10,7 @@ class WorkflowJobSerializer(serializers.HyperlinkedModelSerializer): job_settings = TransparentField(required=False) input_ports = InputPortSerializer(many=True, read_only=True) output_ports = OutputPortSerializer(many=True, read_only=True) + appearance = TransparentField(required=False) class Meta: model = WorkflowJob @@ -34,4 +35,5 @@ class Meta: "group", "created", "updated", + "appearance", ) diff --git a/rodan/serializers/workflowjobcoordinateset.py b/rodan/serializers/workflowjobcoordinateset.py deleted file mode 100644 index 477108885..000000000 --- a/rodan/serializers/workflowjobcoordinateset.py +++ /dev/null @@ -1,20 +0,0 @@ -from rodan.models.workflowjobcoordinateset import WorkflowJobCoordinateSet -from rest_framework import serializers -from rodan.serializers import TransparentField - - -class WorkflowJobCoordinateSetSerializer(serializers.HyperlinkedModelSerializer): - data = TransparentField(required=False) - - class Meta: - model = WorkflowJobCoordinateSet - read_only_fields = ("created", "updated") - fields = ( - "url", - "uuid", - "workflow_job", - "data", - "user_agent", - "created", - "updated", - ) diff --git a/rodan/serializers/workflowjobgroup.py b/rodan/serializers/workflowjobgroup.py index b974587fc..96e54775d 100644 --- a/rodan/serializers/workflowjobgroup.py +++ b/rodan/serializers/workflowjobgroup.py @@ -3,9 +3,12 @@ from rodan.serializers.workflow import version_map from django.conf import settings from rest_framework import serializers +from rodan.serializers import TransparentField class WorkflowJobGroupSerializer(serializers.HyperlinkedModelSerializer): + appearance = TransparentField(required=False) + class Meta: model = WorkflowJobGroup read_only_fields = ("created", "updated", "origin", "workflow") @@ -19,6 +22,7 @@ class Meta: "workflow_jobs", "created", "updated", + "appearance", ) def validate_workflow_jobs(self, wfjs): diff --git a/rodan/serializers/workflowjobgroupcoordinateset.py b/rodan/serializers/workflowjobgroupcoordinateset.py deleted file mode 100644 index 7fe0091d9..000000000 --- a/rodan/serializers/workflowjobgroupcoordinateset.py +++ /dev/null @@ -1,20 +0,0 @@ -from rodan.models.workflowjobgroupcoordinateset import WorkflowJobGroupCoordinateSet -from rest_framework import serializers -from rodan.serializers import TransparentField - - -class WorkflowJobGroupCoordinateSetSerializer(serializers.HyperlinkedModelSerializer): - data = TransparentField(required=False) - - class Meta: - model = WorkflowJobGroupCoordinateSet - read_only_fields = ("created", "updated") - fields = ( - "url", - "uuid", - "workflow_job_group", - "data", - "user_agent", - "created", - "updated", - ) diff --git a/rodan/settings.py b/rodan/settings.py index 5c1515a2d..ea581df1e 100644 --- a/rodan/settings.py +++ b/rodan/settings.py @@ -120,7 +120,8 @@ # Resource thumbnail # THUMBNAIL_EXT = "jpg" # Supported Workflow serialization versions -- see rodan.views.workflow.version_map -RODAN_WORKFLOW_SERIALIZATION_FORMAT_VERSION = 0.1 +# RODAN_WORKFLOW_SERIALIZATION_FORMAT_VERSION = 0.1 +RODAN_WORKFLOW_SERIALIZATION_FORMAT_VERSION = 0.2 # 30 days. NULL: never expire RODAN_RESULTS_PACKAGE_AUTO_EXPIRY_SECONDS = 30 * 24 * 60 * 60 # Default: 15 seconds before the authentication token expires. diff --git a/rodan/test/test_permission.py b/rodan/test/test_permission.py index a96e4e795..8d019435f 100644 --- a/rodan/test/test_permission.py +++ b/rodan/test/test_permission.py @@ -549,87 +549,87 @@ def test_all(self): ) self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) - # WorkflowJobCoordinateSet - for u in [ - self.test_worker, - self.test_worker2, - self.test_admin, - self.test_creator, - ]: - workflowjobcoordinateset = mommy.make( - "rodan.Workflowjobcoordinateset", workflow_job=workflowjob - ) - self.client.force_authenticate(user=u) - - response = self.client.get(reverse("workflowjobcoordinateset-list")) - self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(response.data["count"], 1) - - response = self.client.get( - reverse( - "workflowjobcoordinateset-detail", - kwargs={"pk": workflowjobcoordinateset.pk}, - ) - ) - self.assertEqual(response.status_code, status.HTTP_200_OK) - - response = self.client.patch( - reverse( - "workflowjobcoordinateset-detail", - kwargs={"pk": workflowjobcoordinateset.pk}, - ), - {"user_agent": "new ua{0}".format(u.username)}, - format="json", - ) - self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual( - response.data["user_agent"], "new ua{0}".format(u.username) - ) - - response = self.client.delete( - reverse( - "workflowjobcoordinateset-detail", - kwargs={"pk": workflowjobcoordinateset.pk}, - format="json", - ) - ) - self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) - - workflowjobcoordinateset = mommy.make( - "rodan.Workflowjobcoordinateset", workflow_job=workflowjob - ) - self.client.force_authenticate(user=self.test_outsider) - - response = self.client.get(reverse("workflowjobcoordinateset-list")) - self.assertEqual(response.status_code, status.HTTP_200_OK) - self.assertEqual(response.data["count"], 0) - - response = self.client.get( - reverse( - "workflowjobcoordinateset-detail", - kwargs={"pk": workflowjobcoordinateset.pk}, - ) - ) - self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + # # WorkflowJobCoordinateSet + # for u in [ + # self.test_worker, + # self.test_worker2, + # self.test_admin, + # self.test_creator, + # ]: + # workflowjobcoordinateset = mommy.make( + # "rodan.Workflowjobcoordinateset", workflow_job=workflowjob + # ) + # self.client.force_authenticate(user=u) + + # response = self.client.get(reverse("workflowjobcoordinateset-list")) + # self.assertEqual(response.status_code, status.HTTP_200_OK) + # self.assertEqual(response.data["count"], 1) + + # response = self.client.get( + # reverse( + # "workflowjobcoordinateset-detail", + # kwargs={"pk": workflowjobcoordinateset.pk}, + # ) + # ) + # self.assertEqual(response.status_code, status.HTTP_200_OK) + + # response = self.client.patch( + # reverse( + # "workflowjobcoordinateset-detail", + # kwargs={"pk": workflowjobcoordinateset.pk}, + # ), + # {"user_agent": "new ua{0}".format(u.username)}, + # format="json", + # ) + # self.assertEqual(response.status_code, status.HTTP_200_OK) + # self.assertEqual( + # response.data["user_agent"], "new ua{0}".format(u.username) + # ) + + # response = self.client.delete( + # reverse( + # "workflowjobcoordinateset-detail", + # kwargs={"pk": workflowjobcoordinateset.pk}, + # format="json", + # ) + # ) + # self.assertEqual(response.status_code, status.HTTP_204_NO_CONTENT) + + # workflowjobcoordinateset = mommy.make( + # "rodan.Workflowjobcoordinateset", workflow_job=workflowjob + # ) + # self.client.force_authenticate(user=self.test_outsider) + + # response = self.client.get(reverse("workflowjobcoordinateset-list")) + # self.assertEqual(response.status_code, status.HTTP_200_OK) + # self.assertEqual(response.data["count"], 0) - response = self.client.patch( - reverse( - "workflowjobcoordinateset-detail", - kwargs={"pk": workflowjobcoordinateset.pk}, - ), - {"user_agent": "new ua"}, - format="json", - ) - self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + # response = self.client.get( + # reverse( + # "workflowjobcoordinateset-detail", + # kwargs={"pk": workflowjobcoordinateset.pk}, + # ) + # ) + # self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) - response = self.client.delete( - reverse( - "workflowjobcoordinateset-detail", - kwargs={"pk": workflowjobcoordinateset.pk}, - format="json", - ) - ) - self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + # response = self.client.patch( + # reverse( + # "workflowjobcoordinateset-detail", + # kwargs={"pk": workflowjobcoordinateset.pk}, + # ), + # {"user_agent": "new ua"}, + # format="json", + # ) + # self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) + + # response = self.client.delete( + # reverse( + # "workflowjobcoordinateset-detail", + # kwargs={"pk": workflowjobcoordinateset.pk}, + # format="json", + # ) + # ) + # self.assertEqual(response.status_code, status.HTTP_404_NOT_FOUND) # WorkflowJobGroup diff --git a/rodan/urls.py b/rodan/urls.py index c6aaa7519..b4d4c34e4 100644 --- a/rodan/urls.py +++ b/rodan/urls.py @@ -52,12 +52,6 @@ from rodan.views.resourcetype import ResourceTypeList, ResourceTypeDetail from rodan.views.output import OutputList, OutputDetail from rodan.views.input import InputList, InputDetail -from rodan.views.workflowjobcoordinateset import WorkflowJobCoordinateSetList -from rodan.views.workflowjobcoordinateset import WorkflowJobCoordinateSetDetail -from rodan.views.workflowjobgroupcoordinateset import WorkflowJobGroupCoordinateSetList -from rodan.views.workflowjobgroupcoordinateset import ( - WorkflowJobGroupCoordinateSetDetail -) from rodan.views.taskqueue import ( TaskQueueActiveView, TaskQueueScheduledView, @@ -276,26 +270,6 @@ InteractiveWorkingView.as_view(), name="interactive-working", ), - url( - r"^api/workflowjobcoordinatesets/$", - WorkflowJobCoordinateSetList.as_view(), - name="workflowjobcoordinateset-list", - ), - url( - r"^api/workflowjobcoordinateset/(?P[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$", # noqa - WorkflowJobCoordinateSetDetail.as_view(), - name="workflowjobcoordinateset-detail", - ), - url( - r"^api/workflowjobgroupcoordinatesets/$", - WorkflowJobGroupCoordinateSetList.as_view(), - name="workflowjobgroupcoordinateset-list", - ), - url( - r"^api/workflowjobgroupcoordinateset/(?P[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12})/$", # noqa - WorkflowJobGroupCoordinateSetDetail.as_view(), - name="workflowjobgroupcoordinateset-detail", - ), url(r"^api/auth/me/", AuthMeView.as_view(), name="auth-me"), url( r"^api/auth/register/", diff --git a/rodan/views/main.py b/rodan/views/main.py index 984ef1a67..84466d0d7 100644 --- a/rodan/views/main.py +++ b/rodan/views/main.py @@ -81,12 +81,6 @@ def get(self, request, format=None): "taskqueue-status", request=request, format=format ), # 'taskqueue-config': reverse('taskqueue-config', request=request, format=format), - "workflowjobcoordinatesets": reverse( - "workflowjobcoordinateset-list", request=request, format=format - ), - "workflowjobgroupcoordinatesets": reverse( - "workflowjobgroupcoordinateset-list", request=request, format=format - ), "auth-me": reverse("auth-me", request=request, format=format), "auth-register": reverse( "auth-register", request=request, format=format diff --git a/rodan/views/workflowjobcoordinateset.py b/rodan/views/workflowjobcoordinateset.py deleted file mode 100644 index cfffc5728..000000000 --- a/rodan/views/workflowjobcoordinateset.py +++ /dev/null @@ -1,45 +0,0 @@ -from rest_framework import generics -from rest_framework import permissions -import django_filters -from rodan.models import WorkflowJobCoordinateSet -from rodan.serializers.workflowjobcoordinateset import ( - WorkflowJobCoordinateSetSerializer -) -from rodan.permissions import CustomObjectPermissions - - -class WorkflowJobCoordinateSetList(generics.ListCreateAPIView): - """ - Returns a list of all WorkflowJobCoordinateSets. Accepts a POST request - with a data body to create a new WorkflowJobCoordinateSet. POST requests - will return the newly-created WorkflowJobCoordinateSet object. - """ - - permission_classes = (permissions.IsAuthenticated, CustomObjectPermissions) - _ignore_model_permissions = True - queryset = WorkflowJobCoordinateSet.objects.all() - serializer_class = WorkflowJobCoordinateSetSerializer - - class filter_class(django_filters.FilterSet): - workflow = django_filters.CharFilter(name="workflow_job__workflow") - - class Meta: - model = WorkflowJobCoordinateSet - fields = { - "uuid": ["exact"], - "updated": ["lt", "gt"], - "workflow_job": ["exact"], - "user_agent": ["exact", "icontains"], - "created": ["lt", "gt"], - } - - -class WorkflowJobCoordinateSetDetail(generics.RetrieveUpdateDestroyAPIView): - """ - Performs operations on a single WorkflowJobCoordinateSet instance. - """ - - permission_classes = (permissions.IsAuthenticated, CustomObjectPermissions) - _ignore_model_permissions = True - queryset = WorkflowJobCoordinateSet.objects.all() - serializer_class = WorkflowJobCoordinateSetSerializer diff --git a/rodan/views/workflowjobgroupcoordinateset.py b/rodan/views/workflowjobgroupcoordinateset.py deleted file mode 100644 index 7bd361818..000000000 --- a/rodan/views/workflowjobgroupcoordinateset.py +++ /dev/null @@ -1,45 +0,0 @@ -from rest_framework import generics -from rest_framework import permissions -import django_filters -from rodan.models import WorkflowJobGroupCoordinateSet -from rodan.serializers.workflowjobgroupcoordinateset import ( - WorkflowJobGroupCoordinateSetSerializer -) -from rodan.permissions import CustomObjectPermissions - - -class WorkflowJobGroupCoordinateSetList(generics.ListCreateAPIView): - """ - Returns a list of all WorkflowJobGroupCoordinateSets. Accepts a POST request - with a data body to create a new WorkflowJobCoordinateSet. POST requests - will return the newly-created WorkflowJobCoordinateSet object. - """ - - permission_classes = (permissions.IsAuthenticated, CustomObjectPermissions) - _ignore_model_permissions = True - queryset = WorkflowJobGroupCoordinateSet.objects.all() - serializer_class = WorkflowJobGroupCoordinateSetSerializer - - class filter_class(django_filters.FilterSet): - workflow = django_filters.CharFilter(name="workflow_job_group__workflow") - - class Meta: - model = WorkflowJobGroupCoordinateSet - fields = { - "uuid": ["exact"], - "updated": ["lt", "gt"], - "workflow_job_group": ["exact"], - "user_agent": ["exact", "icontains"], - "created": ["lt", "gt"], - } - - -class WorkflowJobGroupCoordinateSetDetail(generics.RetrieveUpdateDestroyAPIView): - """ - Performs operations on a single WorkflowJobGroupCoordinateSet instance. - """ - - permission_classes = (permissions.IsAuthenticated, CustomObjectPermissions) - _ignore_model_permissions = True - queryset = WorkflowJobGroupCoordinateSet.objects.all() - serializer_class = WorkflowJobGroupCoordinateSetSerializer