diff options
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r-- | archaeological_context_records/models.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 4588e6465..1f79f663d 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -43,6 +43,7 @@ from ishtar_common.models import Document, GeneralType, \ DocumentItem from archaeological_operations.models import Operation, Period, Parcel, \ ArchaeologicalSite +from ishtar_common.model_managers import UUIDModelManager class DatingType(GeneralType): @@ -80,6 +81,7 @@ class Dating(models.Model): blank=True, null=True) precise_dating = models.TextField(_("Precise dating"), blank=True, null=True) + objects = UUIDModelManager() class Meta: verbose_name = _("Dating") @@ -92,6 +94,9 @@ class Dating(models.Model): return str(self.period) return "%s (%s-%s)" % (self.period, start_date, end_date) + def natural_key(self): + return self.uuid, + def get_values(self, prefix='', no_values=False): return { prefix + "period": str(self.period), @@ -448,9 +453,10 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, DOWN_MODEL_UPDATE = ["base_finds"] history = HistoricalRecords(bases=[HistoryModel]) - objects = ExternalIdManager() + objects = UUIDModelManager() # fields + uuid = models.UUIDField(default=uuid.uuid4) external_id = models.TextField(_("External ID"), blank=True, null=True) auto_external_id = models.BooleanField( _("External ID is set automatically"), default=False) @@ -552,7 +558,7 @@ class ContextRecord(BulkUpdatedItem, DocumentItem, BaseHistorizedItem, ordering = ('cached_label',) def natural_key(self): - return (self.external_id, ) + return (self.uuid, ) @property def name(self): |