Skip to content
Snippets Groups Projects
Commit 30981eca authored by Mario Raciti's avatar Mario Raciti
Browse files

TMSS-778: Add error_reason field to Subtask model; update filterset and...

TMSS-778: Add error_reason field to Subtask model; update filterset and serializer for the Subtask model
parent 1c3e6157
No related branches found
No related tags found
2 merge requests!634WIP: COBALT commissioning delta,!610Resolve TMSS-778
......@@ -661,6 +661,7 @@ class Migration(migrations.Migration):
('actual_on_sky_stop_time', models.DateTimeField(help_text='The time the observation actually stopped recording (NULLable).', null=True)),
('primary', models.BooleanField(db_index=True, default=False, help_text='TRUE if this is the one-and-only primary subtask in a parent TaskBlueprint.')),
('specifications_doc', django.contrib.postgres.fields.jsonb.JSONField(help_text='Final specifications, as input for the controller.')),
('error_reason', models.CharField(null=True, max_length=200, help_text='Reason why the Subtask went to error.')),
('raw_feedback', models.CharField(help_text='The raw feedback for this Subtask', max_length=1048576, null=True)),
],
options={
......
......@@ -152,6 +152,7 @@ class Subtask(BasicCommon, ProjectPropertyMixin, TemplateSchemaMixin):
cluster = ForeignKey('Cluster', null=True, on_delete=PROTECT, help_text='Where the Subtask is scheduled to run (NULLable).')
# resource_claim = ForeignKey("ResourceClaim", null=False, on_delete=PROTECT) # todo <-- how is this external reference supposed to work?
created_or_updated_by_user = ForeignKey(User, null=True, editable=False, on_delete=PROTECT, help_text='The user who created / updated the subtask.')
error_reason = CharField(null=True, max_length=200, help_text='Reason why the Subtask went to error.')
raw_feedback = CharField(null=True, max_length=1048576, help_text='The raw feedback for this Subtask')
global_identifier = OneToOneField('SIPidentifier', null=False, editable=False, on_delete=PROTECT, help_text='The global unique identifier for LTA SIP.')
path_to_project = 'task_blueprint__scheduling_unit_blueprint__draft__scheduling_set__project'
......
......@@ -6,6 +6,7 @@ import logging
logger = logging.getLogger(__name__)
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from .. import models
from .widgets import JSONEditorField
from .common import FloatDurationField, RelationalHyperlinkedModelSerializer, AbstractTemplateSerializer, DynamicRelationalHyperlinkedModelSerializer
......@@ -74,6 +75,10 @@ class SubtaskSerializer(DynamicRelationalHyperlinkedModelSerializer):
input_dataproducts = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dataproduct-detail')
output_dataproducts = serializers.HyperlinkedRelatedField(many=True, read_only=True, view_name='dataproduct-detail')
def validate_error_reason(self, value): # Make the error_reason field editable only once
if self.instance and self.instance.error_reason != None:
raise ValidationError("You may not edit error_reason")
return value
class Meta:
model = models.Subtask
......
......@@ -127,6 +127,7 @@ class SubTaskFilter(property_filters.PropertyFilterSet):
id_max = filters.NumberFilter(field_name='id', lookup_expr='lte')
state = filters.ModelMultipleChoiceFilter(field_name='state', queryset=models.SubtaskState.objects.all())
name = filters.CharFilter(field_name='task_blueprint__scheduling_unit_blueprint__name', lookup_expr='icontains') # todo: correct name?
error_reason = filters.CharFilter(field_name='error_reason', lookup_expr='icontains')
on_sky_start_time__lt = property_filters.PropertyIsoDateTimeFilter(field_name='on_sky_start_time', lookup_expr='lt')
on_sky_start_time__gt = property_filters.PropertyIsoDateTimeFilter(field_name='on_sky_start_time', lookup_expr='gt')
on_sky_stop_time__lt = property_filters.PropertyIsoDateTimeFilter(field_name='on_sky_stop_time', lookup_expr='lt')
......
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