Skip to content
Snippets Groups Projects
Commit 3a4a6e99 authored by Jorrit Schaap's avatar Jorrit Schaap
Browse files

TMSS-2886: added SchedulingUnitBlueprintPublicSerializer

parent 1957fd6f
No related branches found
No related tags found
No related merge requests found
......@@ -335,6 +335,30 @@ class SchedulingUnitBlueprintSlimSerializer(serializers.ModelSerializer):
raise NotImplementedError("This serializer should only be used for fast querying existing scheduling units")
class SchedulingUnitBlueprintPublicSerializer(serializers.ModelSerializer):
'''A read-only serializer exposing public non-sensitive properties.'''
project = serializers.StringRelatedField(source='draft.scheduling_set.project.name', label='project', read_only=True)
on_sky_duration = FloatDurationField(read_only=True)
target_pointings_astropy = serializers.StringRelatedField(label='targets', read_only=True)
class Meta:
model = models.SchedulingUnitBlueprint
read_only_fields = ['id',
'status',
'on_sky_start_time',
'on_sky_stop_time',
'on_sky_duration',
'target_pointings_astropy',
'project']
fields = read_only_fields
def create(self, validated_data):
raise NotImplementedError("This is a read-only serializer")
def update(self, instance, validated_data):
raise NotImplementedError("This is a read-only serializer")
class TaskBlueprintSlimSerializer(serializers.ModelSerializer):
'''A small 'slim' serializer for the most relevant properties.'''
duration = FloatDurationField(read_only=True)
......
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