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

TMSS-671: removed obsolete self.__original_scheduling_constraints_template_id...

TMSS-671: removed obsolete self.__original_scheduling_constraints_template_id and self.__original_scheduling_constraints_doc. Removed addidion of non-required defaults to constraints_doc, which can have side effects the user did not intent
parent f23998f3
Branches
Tags
1 merge request!715TMSS-671 & TMSS-1135 & TMSS-1332
......@@ -609,7 +609,9 @@ class SchedulingUnitDraft(NamedCommon, TemplateSchemaMixin, ProjectPropertyMixin
if self.piggyback_allowed_aartfaac is None and hasattr(self, 'scheduling_set'):
self.piggyback_allowed_aartfaac = self.scheduling_set.project.piggyback_allowed_aartfaac
self.annotate_validate_add_defaults_to_doc_using_template('scheduling_constraints_doc', 'scheduling_constraints_template')
# we intentionally do not add defaults to scheduling_constraints_doc
# because that would add default items which the user did not specify,
# and for scheduling contraints this can have unforeseen sideeffects that the user did not intent.
super().save(force_insert, force_update, using, update_fields)
......@@ -744,21 +746,6 @@ class SchedulingUnitBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, NamedCo
global_identifier = OneToOneField('SIPidentifier', null=False, editable=False, on_delete=PROTECT, help_text='The global unique identifier for LTA SIP.')
path_to_project = 'draft__scheduling_set__project'
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# keep original scheduling constraints to detect changes on save
# Note: we cannot use self.scheduling_constraints_doc here since that causes an infinite loop of update_from_db
if 'scheduling_constraints_doc' in kwargs.keys():
self.__original_scheduling_constraints_doc = kwargs['scheduling_constraints_doc']
else:
field_names = [f.name for f in self._meta.fields]
if len(args) == len(field_names):
self.__original_scheduling_constraints_doc = args[field_names.index('scheduling_constraints_doc')]
else:
self.__original_scheduling_constraints_doc = None
self.__original_scheduling_constraints_template_id = self.scheduling_constraints_template_id
def save(self, force_insert=False, force_update=False, using=None, update_fields=None):
SIPidentifier.assign_new_id_to_model(self)
......@@ -769,12 +756,9 @@ class SchedulingUnitBlueprint(ProjectPropertyMixin, TemplateSchemaMixin, NamedCo
if hasattr(self, 'draft'):
setattr(self, copy_field, getattr(self.draft, copy_field))
# make sure the scheduling_constraints_doc contains all required and default values. (no-op when already complete)
self.annotate_validate_add_defaults_to_doc_using_template('scheduling_constraints_doc', 'scheduling_constraints_template')
# update the original constraints value for comparison on next save
self.__original_scheduling_constraints_doc = self.scheduling_constraints_doc
self.__original_scheduling_constraints_template_id = self.scheduling_constraints_template_id
# we intentionally do not add defaults to scheduling_constraints_doc
# because that would add default items which the user did not specify,
# and for scheduling contraints this can have unforeseen sideeffects that the user did not intent.
if self._state.adding and self.interrupts_telescope:
if self.project.can_trigger:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment