diff --git a/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py b/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py index 16cd0f81dbbc9aa01bd10b2121a4b30ccc07156c..9b01a3da93f1916f9119ea7781fe847fe3644db6 100644 --- a/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py +++ b/SAS/TMSS/src/tmss/tmssapp/migrations/0001_initial.py @@ -1,4 +1,4 @@ -# Generated by Django 3.0.6 on 2020-07-14 21:08 +# Generated by Django 3.0.6 on 2020-07-14 21:21 from django.conf import settings import django.contrib.postgres.fields @@ -1019,7 +1019,7 @@ class Migration(migrations.Migration): migrations.AddField( model_name='project', name='cycles', - field=models.ManyToManyField(help_text='Cycles to which this project belongs (NULLable).', null=True, related_name='projects', to='tmssapp.Cycle'), + field=models.ManyToManyField(help_text='Cycles to which this project belongs (NULLable).', related_name='projects', to='tmssapp.Cycle'), ), migrations.AddField( model_name='project', diff --git a/SAS/TMSS/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/src/tmss/tmssapp/models/specification.py index 8a31ff69fd68cff0c7682c42ba0434c2e6950857..d5a83d8971087fc970af8bd925dd5403840fc642 100644 --- a/SAS/TMSS/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/src/tmss/tmssapp/models/specification.py @@ -155,9 +155,8 @@ class PeriodCategory(AbstractChoice): The items in the Choices class below are automagically populated into the database via a data migration.""" class Choices(Enum): - SINGLE = "single" - LONG = "long" - TERM = "term" + SINGLE_CYCLE = "single_cycle" + LONG_TERM = "long_term" UNBOUNDED = "unbounded" @@ -167,11 +166,9 @@ class ProjectCategory(AbstractChoice): class Choices(Enum): REGULAR = "regular" - USER = "user" - SHARED = "shared" - SUPPORT = "support" + USER_SHARED_SUPPORT = "user_shared_support" COMMISSIONING = "commissioning" - DOT = "dot" + DOT = "ddt" TEST = "test" @@ -279,8 +276,7 @@ class Cycle(NamedCommonPK): class Project(NamedCommonPK): - # todo: cycles should be protected since we have to manually decide to clean up projects with a cycle or keep them without cycle, however, ManyToManyField does not allow for that - cycles = ManyToManyField('Cycle', related_name='projects', null=True, help_text='Cycles to which this project belongs (NULLable).') + cycles = ManyToManyField('Cycle', related_name='projects', help_text='Cycles to which this project belongs (NULLable).') priority_rank = FloatField(null=False, help_text='Priority of this project w.r.t. other projects. Projects can interrupt observations of lower-priority projects.') # todo: add if needed: validators=[MinValueValidator(0.0), MaxValueValidator(1.0)] trigger_priority = IntegerField(default=1000, help_text='Priority of this project w.r.t. triggers.') # todo: verify meaning and add to help_text: "Triggers with higher priority than this threshold can interrupt observations of projects." can_trigger = BooleanField(default=False, help_text='True if this project is allowed to supply observation requests on the fly, possibly interrupting currently running observations (responsive telescope).') diff --git a/SAS/TMSS/src/tmss/tmssapp/serializers/specification.py b/SAS/TMSS/src/tmss/tmssapp/serializers/specification.py index 90152f462b3a860e144bb87a210f1c3a3c01bbdc..3a3a3fa3f8b6c9333e4ec51e5d1ec1f2f0f9ebdb 100644 --- a/SAS/TMSS/src/tmss/tmssapp/serializers/specification.py +++ b/SAS/TMSS/src/tmss/tmssapp/serializers/specification.py @@ -212,6 +212,18 @@ class SettingSerializer(serializers.ModelSerializer): fields = '__all__' +class ProjectCategorySerializer(serializers.ModelSerializer): + class Meta: + model = models.ProjectCategory + fields = '__all__' + + +class PeriodCategorySerializer(serializers.ModelSerializer): + class Meta: + model = models.PeriodCategory + fields = '__all__' + + class SchedulingSetSerializer(RelationalHyperlinkedModelSerializer): # Create a JSON editor form to replace the simple text field based on the schema in the template that this diff --git a/SAS/TMSS/src/tmss/tmssapp/viewsets/specification.py b/SAS/TMSS/src/tmss/tmssapp/viewsets/specification.py index 93ab6971734d1c740e52c75b4c6e75407a5b7dd0..5b9443860cf54eeb7da7d494267dc816cf608a23 100644 --- a/SAS/TMSS/src/tmss/tmssapp/viewsets/specification.py +++ b/SAS/TMSS/src/tmss/tmssapp/viewsets/specification.py @@ -208,6 +208,16 @@ class SettingViewSet(LOFARViewSet): serializer_class = serializers.SettingSerializer +class PeriodCategoryViewSet(LOFARViewSet): + queryset = models.PeriodCategory.objects.all() + serializer_class = serializers.PeriodCategorySerializer + + +class ProjectCategoryViewSet(LOFARViewSet): + queryset = models.ProjectCategory.objects.all() + serializer_class = serializers.ProjectCategorySerializer + + class SchedulingUnitDraftViewSet(LOFARViewSet): queryset = models.SchedulingUnitDraft.objects.all() serializer_class = serializers.SchedulingUnitDraftSerializer diff --git a/SAS/TMSS/src/tmss/urls.py b/SAS/TMSS/src/tmss/urls.py index 6dda70922b4b63118f7deed3c8e9c9a08b3dea9a..ba637bdea81fb837c0f61d95819e5d8187d4b281 100644 --- a/SAS/TMSS/src/tmss/urls.py +++ b/SAS/TMSS/src/tmss/urls.py @@ -87,6 +87,8 @@ router.register(r'datatype', viewsets.DatatypeViewSet) router.register(r'dataformat', viewsets.DataformatViewSet) router.register(r'copy_reason', viewsets.CopyReasonViewSet) router.register(r'flag', viewsets.FlagViewSet) +router.register(r'period_category', viewsets.PeriodCategoryViewSet) +router.register(r'project_category', viewsets.ProjectCategoryViewSet) # templates router.register(r'generator_template', viewsets.GeneratorTemplateViewSet)