Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
atdb-ldv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ASTRON SDC
atdb-ldv
Commits
9b0cf5c6
Commit
9b0cf5c6
authored
4 years ago
by
Mattia Mancini
Browse files
Options
Downloads
Patches
Plain Diff
Remove not necessary fields
parent
e0c92c09
No related branches found
No related tags found
1 merge request
!1
Workflow related serializer
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
atdb/taskdatabase/models.py
+0
-3
0 additions, 3 deletions
atdb/taskdatabase/models.py
atdb/taskdatabase/serializers.py
+14
-14
14 additions, 14 deletions
atdb/taskdatabase/serializers.py
atdb/taskdatabase/services/signals.py
+0
-23
0 additions, 23 deletions
atdb/taskdatabase/services/signals.py
with
14 additions
and
40 deletions
atdb/taskdatabase/models.py
+
0
−
3
View file @
9b0cf5c6
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
atdb/taskdatabase/serializers.py
+
14
−
14
View file @
9b0cf5c6
...
...
@@ -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
):
...
...
This diff is collapsed.
Click to expand it.
atdb/taskdatabase/services/signals.py
+
0
−
23
View file @
9b0cf5c6
...
...
@@ -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
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment