From 70574c801057e60d4db408bfd036ee3c57fa3b25 Mon Sep 17 00:00:00 2001 From: Jorrit Schaap <schaap@astron.nl> Date: Tue, 12 Oct 2021 16:23:54 +0200 Subject: [PATCH] TMSS-1093: made ReservationStrategyTemplate as subclass of BaseStrategyTemplate --- .../migrations/0004_remove_obsolete_fields.py | 19 ++++++++++++++++++- .../src/tmss/tmssapp/models/specification.py | 6 +----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0004_remove_obsolete_fields.py b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0004_remove_obsolete_fields.py index d02ee5789da..03c77d0129f 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0004_remove_obsolete_fields.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/migrations/0004_remove_obsolete_fields.py @@ -1,7 +1,7 @@ # Generated by Django 3.0.9 on 2021-10-11 15:44 import django.contrib.postgres.fields.jsonb -from django.db import migrations +from django.db import migrations, models class Migration(migrations.Migration): @@ -33,4 +33,21 @@ class Migration(migrations.Migration): name='template', field=django.contrib.postgres.fields.jsonb.JSONField(help_text='JSON-data document compliant with the JSON-schema in the referenced template. This strategy template is like a predefined recipe with all the correct settings, and defines which parameters the user can alter.'), ), + migrations.AlterField( + model_name='reservationstrategytemplate', + name='template', + field=django.contrib.postgres.fields.jsonb.JSONField( + help_text='JSON-data document compliant with the JSON-schema in the referenced template. This strategy template is like a predefined recipe with all the correct settings, and defines which parameters the user can alter.'), + ), + migrations.AlterField( + model_name='reservationstrategytemplate', + name='version', + field=models.IntegerField(editable=False, + help_text='Version of this template (with respect to other templates of the same name)'), + ), + migrations.AddConstraint( + model_name='reservationstrategytemplate', + constraint=models.UniqueConstraint(fields=('name', 'version'), + name='reservationstrategytemplate_unique_name_version'), + ), ] diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py index 96ff93e3940..7a66ab0be2e 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/specification.py @@ -332,17 +332,13 @@ class TaskRelationSelectionTemplate(Template): pass -class ReservationStrategyTemplate(NamedCommon): +class ReservationStrategyTemplate(BaseStrategyTemplate): ''' A ReservationStrategyTemplate is a template in the sense that it serves as a template to fill in json data objects conform its referred reservation_template. It is however not derived from the (abstract) Template super-class, because the Template super class is for JSON schemas, not JSON data objects. ''' - version = CharField(max_length=128, help_text='Version of this template (with respect to other templates of the same name).') - template = JSONField(null=False, help_text='JSON-data compliant with the JSON-schema in the reservation_template. ' - 'This reservation strategy template like a predefined recipe with all ' - 'the correct settings, and defines which parameters the user can alter.') reservation_template = ForeignKey("ReservationTemplate", on_delete=PROTECT, null=False, help_text="") def save(self, force_insert=False, force_update=False, using=None, update_fields=None): -- GitLab