diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-16 12:38:41 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-16 12:38:41 +0200 |
commit | fe78f0db71ac7a9528925492c8521496dc6c36ed (patch) | |
tree | fa0614969e604e65396fabf9a48cbd7c97a410e8 /archaeological_context_records | |
parent | 5d0750488690ec698857aa40e4e16761d3aae613 (diff) | |
download | Ishtar-fe78f0db71ac7a9528925492c8521496dc6c36ed.tar.bz2 Ishtar-fe78f0db71ac7a9528925492c8521496dc6c36ed.zip |
Manage ope prefixes with the profile
Diffstat (limited to 'archaeological_context_records')
-rw-r--r-- | archaeological_context_records/models.py | 8 | ||||
-rw-r--r-- | archaeological_context_records/tests.py | 6 |
2 files changed, 9 insertions, 5 deletions
diff --git a/archaeological_context_records/models.py b/archaeological_context_records/models.py index 3cb0313dd..e3c7ff4e5 100644 --- a/archaeological_context_records/models.py +++ b/archaeological_context_records/models.py @@ -35,7 +35,7 @@ from ishtar_common.models import Document, GeneralType, \ BaseHistorizedItem, HistoricalRecords, OwnPerms, ShortMenuItem, \ GeneralRelationType, GeneralRecordRelations, post_delete_record_relation,\ post_save_cache, ValueGetter, BulkUpdatedItem, \ - RelationItem, Town + RelationItem, Town, get_current_profile from archaeological_operations.models import Operation, Period, Parcel, \ ArchaeologicalSite @@ -436,6 +436,8 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, return kwargs['transaction_id'] = transaction_id + profile = get_current_profile() + sql = """ UPDATE "archaeological_context_records_contextrecord" AS cr SET cached_label = @@ -469,8 +471,8 @@ class ContextRecord(BulkUpdatedItem, BaseHistorizedItem, SELECT id FROM archaeological_context_records_contextrecord WHERE {where} ); - """.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, where=where) with connection.cursor() as c: c.execute(sql, args) diff --git a/archaeological_context_records/tests.py b/archaeological_context_records/tests.py index bf8864d56..2f676c194 100644 --- a/archaeological_context_records/tests.py +++ b/archaeological_context_records/tests.py @@ -28,7 +28,7 @@ from django.core.urlresolvers import reverse from django.test.client import Client from ishtar_common.models import IshtarSiteProfile, ImporterModel, \ - UserProfile, ProfileType, Town, Area + UserProfile, ProfileType, Town, Area, get_current_profile from archaeological_operations.tests import OperationInitTest, \ ImportTest, FILE_TOWNS_FIXTURES, FILE_FIXTURES, OPERATION_TOWNS_FIXTURES @@ -293,7 +293,9 @@ class ContextRecordTest(ContextRecordInit, TestCase): cr.operation.code_patriarche = "PATRIARCHE" cr.operation.save() cr = models.ContextRecord.objects.get(pk=cr.pk) - self.assertIn(settings.ISHTAR_OPE_PREFIX.lower() + "patriarch", + + profile = get_current_profile() + self.assertIn(profile.operation_prefix.lower() + "patriarch", cr.search_vector) def test_upstream_cache_update(self): |