diff options
Diffstat (limited to 'archaeological_context_records/models.py')
-rw-r--r-- | archaeological_context_records/models.py | 22 |
1 files changed, 5 insertions, 17 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 70858ea31..8dd082e7b 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -33,7 +33,7 @@ from ishtar_common.utils import cached_label_changed from ishtar_common.models import GeneralType, BaseHistorizedItem, \ HistoricalRecords, OwnPerms, ShortMenuItem, Source, GeneralRelationType,\ GeneralRecordRelations, post_delete_record_relation, get_external_id, \ - ImageModel, post_save_cache, ValueGetter, BulkUpdatedItem + ImageModel, post_save_cache, ValueGetter, BulkUpdatedItem, ExternalIdManager from archaeological_operations.models import Operation, Period, Parcel @@ -189,10 +189,12 @@ class CRBulkView(object): """ -class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, ImageModel, OwnPerms, - ValueGetter, ShortMenuItem): +class ContextRecord(ExternalIdManager, BulkUpdatedItem, BaseHistorizedItem, + ImageModel, OwnPerms, ValueGetter, ShortMenuItem): SHOW_URL = 'show-contextrecord' SLUG = 'contextrecord' + EXTERNAL_ID_KEY = 'context_record_external_id' + EXTERNAL_ID_DEPENDENCIES = ['base_finds'] TABLE_COLS = ['label', 'operation__common_name', 'parcel__town__name', 'parcel__label', 'unit'] if settings.COUNTRY == 'fr': @@ -518,20 +520,6 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, ImageModel, OwnPerms, from archaeological_finds.models import FindSource return FindSource.objects.filter(find__base_finds__context_record=self) - def save(self, *args, **kwargs): - returned = super(ContextRecord, self).save(*args, **kwargs) - updated = False - if not self.external_id or self.auto_external_id: - external_id = get_external_id('context_record_external_id', self) - if external_id != self.external_id: - updated = True - self.auto_external_id = True - self.external_id = external_id - if updated: - self._cached_label_checked = False - self.save() - return returned - def fix(self): """ Fix redundant m2m dating association (usually after imports) |