summaryrefslogtreecommitdiff
path: root/archaeological_finds/models_finds.py
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-10-16 12:10:17 +0200
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-10-16 12:10:17 +0200
commit5aa11c751acecb6d5a3a56f45f74d17d64a358d1 (patch)
treead04d9e574e9d1523ae3b967fc781f0b9d2c3238 /archaeological_finds/models_finds.py
parentb6f5261620d6518a0e5a9da1e638ab97be716609 (diff)
downloadIshtar-5aa11c751acecb6d5a3a56f45f74d17d64a358d1.tar.bz2
Ishtar-5aa11c751acecb6d5a3a56f45f74d17d64a358d1.zip
Natural keys for operations, context records, finds, etc.
Diffstat (limited to 'archaeological_finds/models_finds.py')
-rw-r--r--archaeological_finds/models_finds.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py
index bda25f97c..539ba2325 100644
--- a/archaeological_finds/models_finds.py
+++ b/archaeological_finds/models_finds.py
@@ -44,7 +44,7 @@ from archaeological_operations.models import AdministrativeAct, Operation
from archaeological_context_records.models import ContextRecord, Dating
from ishtar_common.models import PRIVATE_FIELDS, SpatialReferenceSystem, \
- BulkUpdatedItem
+ BulkUpdatedItem, ExternalIdManager
class MaterialType(HierarchicalType):
@@ -302,6 +302,7 @@ class BaseFind(BulkUpdatedItem, BaseHistorizedItem, OwnPerms):
PARENT_SEARCH_VECTORS = ['context_record']
BASE_SEARCH_VECTORS = ["label", "description", "comment", "cache_short_id",
"cache_complete_id", "excavation_id"]
+ objects = ExternalIdManager()
class Meta:
verbose_name = _(u"Base find")
@@ -317,6 +318,9 @@ class BaseFind(BulkUpdatedItem, BaseHistorizedItem, OwnPerms):
def __unicode__(self):
return self.label
+ def natural_key(self):
+ return (self.external_id, )
+
def get_last_find(self):
# TODO: manage virtuals - property(last_find) ?
finds = self.find.filter().order_by("-order").all()
@@ -874,6 +878,7 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,
M2M_SEARCH_VECTORS = [
"datings__period__label", "object_types__label", "integrities__label",
"remarkabilities__label", "material_types__label"]
+ objects = ExternalIdManager()
# fields
base_finds = models.ManyToManyField(BaseFind, verbose_name=_(u"Base find"),
@@ -1018,6 +1023,9 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms,
)
ordering = ('cached_label',)
+ def natural_key(self):
+ return (self.external_id, )
+
@property
def short_class_name(self):
return _(u"FIND")