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 | 162405c1d1b3ca112ae71b3cc93d3689b9e89822 (patch) | |
tree | fa0614969e604e65396fabf9a48cbd7c97a410e8 /archaeological_operations | |
parent | e653e1ae9a75ae0d634315e99c7600fa3d897fbe (diff) | |
download | Ishtar-162405c1d1b3ca112ae71b3cc93d3689b9e89822.tar.bz2 Ishtar-162405c1d1b3ca112ae71b3cc93d3689b9e89822.zip |
Manage ope prefixes with the profile
Diffstat (limited to 'archaeological_operations')
-rw-r--r-- | archaeological_operations/models.py | 17 | ||||
-rw-r--r-- | archaeological_operations/tests.py | 11 |
2 files changed, 17 insertions, 11 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 828df91e5..9d6264a4d 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -36,7 +36,7 @@ from ishtar_common.models import BaseHistorizedItem, Dashboard, \ HistoricalRecords, IshtarUser, LightHistorizedItem, \ OperationType, Organization, OwnPerms, Person, PersonType, \ post_delete_record_relation, post_save_cache, RelationItem, \ - ShortMenuItem, SourceType, Town, ValueGetter + ShortMenuItem, SourceType, Town, ValueGetter, get_current_profile from ishtar_common.utils import cached_label_changed, \ force_cached_label_changed, mode @@ -831,15 +831,16 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, return BaseFind.objects.filter(context_record__operation=self) def get_reference(self, full=False): + profile = get_current_profile() ref = "" - if settings.COUNTRY == 'fr' and self.code_patriarche: - ref = settings.ISHTAR_OPE_PREFIX + unicode(self.code_patriarche) + if self.code_patriarche: + ref = profile.operation_prefix + unicode(self.code_patriarche) if not full: return ref if self.year and self.operation_code: if ref: ref += u" - " - ref += settings.ISHTAR_DEF_OPE_PREFIX + ref += profile.default_operation_prefix ref += u"-".join((unicode(self.year), unicode(self.operation_code))) return ref or "00" @@ -931,15 +932,17 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter, return "" lbl = unicode(self.operation_code) year = self.year or 0 - lbl = settings.ISHTAR_DEF_OPE_PREFIX \ - + u"%d-%s%s" % (year, (3 - len(lbl)) * "0", lbl) + profile = get_current_profile() + lbl = profile.default_operation_prefix \ + + u"%d-%s%s" % (year, (3 - len(lbl)) * "0", lbl) return lbl @property def full_code_patriarche(self): if not self.code_patriarche: return '' - return settings.ISHTAR_OPE_PREFIX + self.code_patriarche + profile = get_current_profile() + return profile.operation_prefix + self.code_patriarche def clean(self): if not self.operation_code: diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index f50e58eaa..a3cd5fd8d 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -43,7 +43,7 @@ from ishtar_common.models import OrganizationType, Organization, ItemKey, \ Town, ImporterColumn, Person, Author, SourceType, AuthorType, \ DocumentTemplate, PersonType, TargetKeyGroup, JsonDataField, \ JsonDataSection, ImportTarget, FormaterType, CustomForm, ExcludedField, \ - UserProfile, ProfileType, Area, CustomFormJsonField + UserProfile, ProfileType, Area, CustomFormJsonField, get_current_profile from archaeological_files.models import File, FileType from archaeological_context_records.models import Unit, ContextRecord @@ -1103,8 +1103,10 @@ class OperationTest(TestCase, OperationInitTest): # verify the relevance of the update cr = ContextRecord.objects.get(pk=cr.pk) ope_id, parcel_sec, parcel_nb, cr_label = cr.cached_label.split(' | ') - self.assertEqual(ope_id, '{}2011-1'.format( - settings.ISHTAR_DEF_OPE_PREFIX)) + profile = get_current_profile() + + self.assertEqual( + ope_id, '{}2011-1'.format(profile.default_operation_prefix)) base_find = BaseFind.objects.get(pk=base_find.pk) op_code, idx = base_find.cache_short_id.split(' | ') @@ -1126,7 +1128,8 @@ class OperationTest(TestCase, OperationInitTest): operation.save() cr = ContextRecord.objects.get(pk=cr.pk) ope_id, parcel_sec, parcel_nb, cr_label = cr.cached_label.split(' | ') - self.assertEqual(ope_id, '{}666'.format(settings.ISHTAR_OPE_PREFIX)) + + self.assertEqual(ope_id, '{}666'.format(profile.operation_prefix)) base_find = BaseFind.objects.get(pk=base_find.pk) op_code, idx = base_find.cache_short_id.split(' | ') |