Skip to content
Snippets Groups Projects
Commit 9b0cf5c6 authored by Mattia Mancini's avatar Mattia Mancini
Browse files

Remove not necessary fields

parent e0c92c09
No related branches found
No related tags found
1 merge request!1Workflow related serializer
......@@ -31,9 +31,6 @@ class Task(models.Model):
sas_id = models.CharField(max_length=30, blank=True, null=True)
priority = models.IntegerField(default=0)
purge_policy = models.CharField(max_length=5, default="no", blank=True, null=True)
desired_workflow_id = models.CharField(max_length=12, blank=True, null=True)
desired_workflow_uri = models.CharField(max_length=100, blank=True, null=True)
workflow = models.ForeignKey(Workflow, related_name='tasks', on_delete=models.SET_NULL, null=True,blank=True)
inputs = models.JSONField(null=True, blank=True)
outputs = models.JSONField(null=True, blank=True)
......
......@@ -2,19 +2,30 @@ from rest_framework import serializers
from .models import Status, Task, Workflow, LogEntry
class TaskSerializer(serializers.ModelSerializer):
class WorkflowSerializer(serializers.ModelSerializer):
# tasks = serializers.StringRelatedField(
# many=True,
# required=False,
# )
class Meta:
model = Workflow
fields = "__all__"
class TaskSerializer(serializers.ModelSerializer):
status_history = serializers.StringRelatedField(
many=True,
required=False,
)
class Meta:
model = Task
fields = ('id','task_type','taskID',
'desired_predecessor_id','predecessor','successor',
'project','sas_id','priority','purge_policy','skip',
'desired_workflow_id','desired_workflow_uri','workflow',
'workflow',
'status','desired_status',
'inputs','outputs','status_history')
......@@ -26,17 +37,6 @@ class StatusSerializer(serializers.ModelSerializer):
fields = "__all__"
class WorkflowSerializer(serializers.ModelSerializer):
# tasks = serializers.StringRelatedField(
# many=True,
# required=False,
# )
class Meta:
model = Workflow
fields = "__all__"
class LogEntrySerializer(serializers.ModelSerializer):
......
......@@ -34,28 +34,6 @@ def pre_save_task_handler(sender, **kwargs):
handle_pre_save(sender, **kwargs)
def add_workflow(myTaskObject):
desired_workflow_id = myTaskObject.desired_workflow_id
desired_workflow_uri = myTaskObject.desired_workflow_uri
# first try to find the workflow by desired workflow_id
try:
desired_workflow = Workflow.objects.get(id=desired_workflow_id)
except:
desired_workflow = None
if (desired_workflow == None):
# then try workflow_uri
desired_workflow = Workflow.objects.get(workflow_uri=desired_workflow_uri)
# first check if works needs to be done at all
if (myTaskObject.workflow != desired_workflow):
# set the new status
myTaskObject.workflow = desired_workflow
return myTaskObject
def add_predecessor(myTaskObject):
# connect the task to a workflow after posting a (flat) task through the REST API
......@@ -101,7 +79,6 @@ def handle_pre_save(sender, **kwargs):
myStatus.save()
# connect the task to a workflow after posting a (flat) task through the REST API
myTaskObject = add_workflow(myTaskObject)
myTaskObject = add_predecessor(myTaskObject)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment