diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-04 15:32:22 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-09-04 15:33:13 +0200 |
commit | e75781247b085311d75ba380ead2b523b8dba097 (patch) | |
tree | d0dd22cc3b923ca8a2270c121f5b94bdb19dd4c1 /archaeological_context_records/models.py | |
parent | 21fe72642e7b7e9847a178794a1cd9f771f23c0a (diff) | |
download | Ishtar-e75781247b085311d75ba380ead2b523b8dba097.tar.bz2 Ishtar-e75781247b085311d75ba380ead2b523b8dba097.zip |
Serializers: manage context records - uuid for context records
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): |