diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-09-21 00:26:03 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2017-09-21 00:26:03 +0200 |
commit | 0cd398940a316afe8fc7ec2b0102c793c3f4342b (patch) | |
tree | fe78f8109bbae1e761e79bdd7998f639d895f640 /archaeological_finds | |
parent | f46de1b6d4cbf832ce6f22fe82a5377b5e0ed6a4 (diff) | |
download | Ishtar-0cd398940a316afe8fc7ec2b0102c793c3f4342b.tar.bz2 Ishtar-0cd398940a316afe8fc7ec2b0102c793c3f4342b.zip |
Generic manner of managing external id
Diffstat (limited to 'archaeological_finds')
-rw-r--r-- | archaeological_finds/models_finds.py | 14 | ||||
-rw-r--r-- | archaeological_finds/tests.py | 2 |
2 files changed, 8 insertions, 8 deletions
diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index be563f34e..a335eb6ec 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -34,7 +34,7 @@ from ishtar_common.utils import cached_label_changed, post_save_point from ishtar_common.models import GeneralType, ImageModel, BaseHistorizedItem, \ ShortMenuItem, LightHistorizedItem, HistoricalRecords, OwnPerms, Source, \ Person, Basket, post_save_cache, ValueGetter, \ - get_current_profile, ExternalIdManager + get_current_profile from archaeological_operations.models import AdministrativeAct from archaeological_context_records.models import ContextRecord, Dating @@ -150,8 +150,7 @@ class BFBulkView(object): """ -class BaseFind(ExternalIdManager, BulkUpdatedItem, BaseHistorizedItem, - OwnPerms): +class BaseFind(BulkUpdatedItem, BaseHistorizedItem, OwnPerms): EXTERNAL_ID_KEY = 'base_find_external_id' EXTERNAL_ID_DEPENDENCIES = ['find'] label = models.TextField(_(u"Free ID")) @@ -494,8 +493,8 @@ class FBulkView(object): """ -class Find(ExternalIdManager, BulkUpdatedItem, ValueGetter, - BaseHistorizedItem, ImageModel, OwnPerms, ShortMenuItem): +class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, ImageModel, + OwnPerms, ShortMenuItem): EXTERNAL_ID_KEY = 'find_external_id' CHECK_DICT = dict(CHECK_CHOICES) SHOW_URL = 'show-find' @@ -746,10 +745,9 @@ class Find(ExternalIdManager, BulkUpdatedItem, ValueGetter, return lbl def get_first_base_find(self): - q = self.base_finds - if not q.count(): + if not self.base_finds.count(): return - return q.order_by('-pk').all()[0] + return self.base_finds.order_by('-pk').all()[0] @property def reference(self): diff --git a/archaeological_finds/tests.py b/archaeological_finds/tests.py index 05eef2c96..7ae81a1bb 100644 --- a/archaeological_finds/tests.py +++ b/archaeological_finds/tests.py @@ -366,6 +366,7 @@ class FindTest(FindInit, TestCase): "New label")) cr = ContextRecord.objects.get(pk=base_find.context_record.pk) cr.label = "new-label-too" + cr.skip_history_when_saving = True cr.save() base_find = models.BaseFind.objects.get(pk=base_find.pk) find = models.Find.objects.get(pk=find.pk) @@ -374,6 +375,7 @@ class FindTest(FindInit, TestCase): self.assertIn("new-label-too", base_find.external_id) cr.operation.code_patriarche = "PAT" + cr.operation.skip_history_when_saving = True cr.operation.save() base_find = models.BaseFind.objects.get(pk=base_find.pk) find = models.Find.objects.get(pk=find.pk) |