diff --git a/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py b/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py index 7372d9e8b4c70b575c74a30aac2cf085b4fa4191..4a7207cddcdd299af14e45fdd3a59696fcbe124e 100644 --- a/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py +++ b/SAS/TMSS/backend/src/tmss/tmssapp/models/scheduling.py @@ -9,7 +9,7 @@ logger = logging.getLogger(__name__) from datetime import datetime, timedelta from django.db.models import Model, ForeignKey, OneToOneField, CharField, DateTimeField, BooleanField, IntegerField, BigIntegerField, \ - ManyToManyField, CASCADE, SET_NULL, PROTECT, QuerySet, BigAutoField + ManyToManyField, CASCADE, SET_NULL, PROTECT, QuerySet, BigAutoField, UniqueConstraint from django.contrib.postgres.fields import ArrayField, JSONField from django.contrib.auth.models import User from .specification import AbstractChoice, BasicCommon, Template, NamedCommon, annotate_validate_add_defaults_to_doc_using_template @@ -375,6 +375,9 @@ class Dataproduct(BasicCommon): sap = ForeignKey('SAP', on_delete=PROTECT, null=True, related_name="dataproducts", help_text='SAP this dataproduct was generated out of (NULLable).') global_identifier = OneToOneField('SIPidentifier', editable=False, null=False, on_delete=PROTECT, help_text='The global unique identifier for LTA SIP.') + class Meta: + constraints = [UniqueConstraint(fields=['directory', 'filename'], name='%(class)s_unique_path')] + def save(self, force_insert=False, force_update=False, using=None, update_fields=None): annotate_validate_add_defaults_to_doc_using_template(self, 'specifications_doc', 'specifications_template') annotate_validate_add_defaults_to_doc_using_template(self, 'feedback_doc', 'feedback_template')