diff --git a/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py b/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py index 7be8e5ede2835a8c5cc0dd7b3ffd16c750ea8cbb..1995a8a4d23f3d9e386ae397af12f08ff0802b1b 100644 --- a/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py +++ b/SAS/TMSS/src/tmss/tmssapp/models/scheduling.py @@ -143,13 +143,19 @@ class JSONValidatorMixin: """ def validate_specification_against_schema(self): - if not hasattr(self, self.name_of_field_to_validate) or not hasattr(self, self.name_of_template_field): + # catch programming error where Mixin was not provided with required info + if not hasattr(self, 'name_of_field_to_validate') or not hasattr(self, 'name_of_template_field'): raise AttributeError("The enclosing object has to define string attributes 'name_of_field_to_validate' and " "'name_of_template_field' for this Mixin to function.") + # Do nothing if validation info was specifically set to None if self.name_of_field_to_validate is None or self.name_of_template_field is None: return + # Do nothing if _id field is None (which apparently happens when the actual relation is set to None) + if getattr(self, self.name_of_template_field+'_id') is None: + return + jsonfield = getattr(self, self.name_of_field_to_validate) template = getattr(self, self.name_of_template_field)