diff options
| 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 |
| commit | 5aa11c751acecb6d5a3a56f45f74d17d64a358d1 (patch) | |
| tree | ad04d9e574e9d1523ae3b967fc781f0b9d2c3238 /archaeological_finds | |
| parent | b6f5261620d6518a0e5a9da1e638ab97be716609 (diff) | |
| download | Ishtar-5aa11c751acecb6d5a3a56f45f74d17d64a358d1.tar.bz2 Ishtar-5aa11c751acecb6d5a3a56f45f74d17d64a358d1.zip | |
Natural keys for operations, context records, finds, etc.
Diffstat (limited to 'archaeological_finds')
| -rw-r--r-- | archaeological_finds/models_finds.py | 10 | ||||
| -rw-r--r-- | archaeological_finds/models_treatments.py | 6 |
2 files changed, 15 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") diff --git a/archaeological_finds/models_treatments.py b/archaeological_finds/models_treatments.py index 291a75d4c..93a45164b 100644 --- a/archaeological_finds/models_treatments.py +++ b/archaeological_finds/models_treatments.py @@ -27,6 +27,7 @@ from django.template.defaultfilters import slugify from django.utils.translation import ugettext_lazy as _, pgettext_lazy, \ activate, deactivate +from ishtar_common.models import ExternalIdManager from archaeological_finds.models_finds import Find, FindBasket, TreatmentType from archaeological_operations.models import ClosedItem, Operation from archaeological_warehouse.models import Warehouse, Container @@ -113,6 +114,8 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, INT_SEARCH_VECTORS = ["year", "index"] M2M_SEARCH_VECTORS = ['downstream__cached_label', 'upstream__cached_label'] PARENT_SEARCH_VECTORS = ['person', 'organization'] + objects = ExternalIdManager() + label = models.CharField(_(u"Label"), blank=True, null=True, max_length=200) other_reference = models.CharField(_(u"Other ref."), blank=True, null=True, @@ -187,6 +190,9 @@ class Treatment(DashboardFormItem, ValueGetter, BaseHistorizedItem, def short_class_name(self): return _(u"TREATMENT") + def natural_key(self): + return (self.external_id, ) + @classmethod def get_query_owns(cls, ishtaruser): return (Q(history_creator=ishtaruser.user_ptr) | |
