diff options
Diffstat (limited to 'archaeological_operations/models.py')
-rw-r--r-- | archaeological_operations/models.py | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 7d44a8bcf..51f67d723 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -190,11 +190,13 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, operation_type = models.ForeignKey(OperationType, related_name='+', verbose_name=_(u"Operation type")) surface = models.IntegerField(_(u"Surface (m²)"), blank=True, null=True) - remains = models.ManyToManyField("RemainType", verbose_name=_(u'Remains')) + remains = models.ManyToManyField("RemainType", verbose_name=_(u'Remains'), + null=True, blank=True ) towns = models.ManyToManyField(Town, verbose_name=_(u"Towns")) cost = models.IntegerField(_(u"Cost (€)"), blank=True, null=True) # preventive - periods = models.ManyToManyField(Period, verbose_name=_(u"Periods")) + periods = models.ManyToManyField(Period, verbose_name=_(u"Periods"), + null=True, blank=True) scheduled_man_days = models.IntegerField(_(u"Scheduled man-days"), blank=True, null=True) # preventive optional_man_days = models.IntegerField(_(u"Optional man-days"), @@ -203,7 +205,7 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, blank=True, null=True) # preventive if settings.COUNTRY == 'fr': code_patriarche = models.IntegerField(u"Code PATRIARCHE", null=True, - blank=True) + blank=True, unique=True) TABLE_COLS = ['code_patriarche'] + TABLE_COLS code_dracar = models.CharField(u"Code DRACAR", max_length=10, null=True, blank=True) @@ -237,7 +239,7 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, cached_label = models.CharField(_(u"Cached name"), max_length=500, null=True, blank=True) archaeological_sites = models.ManyToManyField(ArchaeologicalSite, - verbose_name=_(u"Archaeological sites")) + verbose_name=_(u"Archaeological sites"), null=True, blank=True) history = HistoricalRecords() class Meta: @@ -374,6 +376,8 @@ class Operation(BaseHistorizedItem, OwnPerms, ValueGetter, ShortMenuItem, return lbl def clean(self): + if not self.operation_code: + return objs = self.__class__.objects.filter(year=self.year, operation_code=self.operation_code) if self.pk: |