From fe78f0db71ac7a9528925492c8521496dc6c36ed Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Thu, 16 Aug 2018 12:38:41 +0200 Subject: Manage ope prefixes with the profile --- archaeological_finds/models_finds.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'archaeological_finds/models_finds.py') diff --git a/archaeological_finds/models_finds.py b/archaeological_finds/models_finds.py index 0fb8229e4..40bcf52c7 100644 --- a/archaeological_finds/models_finds.py +++ b/archaeological_finds/models_finds.py @@ -349,14 +349,15 @@ class BaseFind(BulkUpdatedItem, BaseHistorizedItem, OwnPerms): def _ope_code(self): if not self.context_record.operation: return '' + profile = get_current_profile() ope = self.context_record.operation c_id = [] if ope.code_patriarche: - c_id.append(settings.ISHTAR_OPE_PREFIX + + c_id.append(profile.operation_prefix + ope.code_patriarche) elif ope.year and ope.operation_code: c_id.append( - settings.ISHTAR_DEF_OPE_PREFIX + + profile.default_operation_prefix + unicode(ope.year or '') + u"-" + unicode(ope.operation_code or '')) else: @@ -463,6 +464,8 @@ class BaseFind(BulkUpdatedItem, BaseHistorizedItem, OwnPerms): return kwargs['transaction_id'] = transaction_id + profile = get_current_profile() + sql = """ UPDATE "archaeological_finds_basefind" AS bf SET cache_short_id = @@ -535,8 +538,8 @@ class BaseFind(BulkUpdatedItem, BaseHistorizedItem, OwnPerms): SELECT mybf.id FROM archaeological_finds_basefind mybf {filters} ); - """.format(main_ope_prefix=settings.ISHTAR_OPE_PREFIX, - ope_prefix=settings.ISHTAR_DEF_OPE_PREFIX, + """.format(main_ope_prefix=profile.operation_prefix, + ope_prefix=profile.default_operation_prefix, join=settings.JOINT, filters=filters, zeros=settings.ISHTAR_FINDS_INDEX_ZERO_LEN * "0") with connection.cursor() as c: @@ -1312,6 +1315,9 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, args = [int(find_id)] else: return + + profile = get_current_profile() + sql = """ UPDATE "archaeological_finds_find" AS f SET cached_label = @@ -1346,8 +1352,8 @@ class Find(BulkUpdatedItem, ValueGetter, BaseHistorizedItem, OwnPerms, SELECT myf.id FROM archaeological_finds_find myf {filters} ); - """.format(main_ope_prefix=settings.ISHTAR_OPE_PREFIX, - ope_prefix=settings.ISHTAR_DEF_OPE_PREFIX, + """.format(main_ope_prefix=profile.operation_prefix, + ope_prefix=profile.default_operation_prefix, join=settings.JOINT, filters=filters, zeros=settings.ISHTAR_FINDS_INDEX_ZERO_LEN * "0") with connection.cursor() as c: -- cgit v1.2.3