summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2019-03-11 18:55:33 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2019-04-24 19:41:37 +0200
commit20d5c7d28d127a2ef8deab2ba2c6a7045700b6c8 (patch)
tree28057054e3cea0aa7815dbe0ef21d71219fae5e2 /ishtar_common
parent630b7be7a5ee39bd418b81f8dc88831c1b65b39c (diff)
downloadIshtar-20d5c7d28d127a2ef8deab2ba2c6a7045700b6c8.tar.bz2
Ishtar-20d5c7d28d127a2ef8deab2ba2c6a7045700b6c8.zip
Site translations in forms
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms.py14
-rw-r--r--ishtar_common/models.py16
2 files changed, 29 insertions, 1 deletions
diff --git a/ishtar_common/forms.py b/ishtar_common/forms.py
index 448c06ceb..c7e3fe38c 100644
--- a/ishtar_common/forms.py
+++ b/ishtar_common/forms.py
@@ -548,11 +548,16 @@ class IshtarForm(forms.Form, BSForm):
TYPES = [] # FieldType list
PROFILE_FILTER = {} # profile key associated to field list
HEADERS = {} # field key associated to FormHeader instance
+ SITE_KEYS = {} # archaeological sites fields and associated translation key
+ # to manage translation
def __init__(self, *args, **kwargs):
super(IshtarForm, self).__init__(*args, **kwargs)
- if self.PROFILE_FILTER:
+ profile = None
+ if self.PROFILE_FILTER or self.SITE_KEYS:
profile = models.get_current_profile()
+
+ if self.PROFILE_FILTER:
for profile_key in self.PROFILE_FILTER:
if not getattr(profile, profile_key):
for field_key in self.PROFILE_FILTER[profile_key]:
@@ -562,6 +567,13 @@ class IshtarForm(forms.Form, BSForm):
return
for field in self.TYPES:
self._init_type(field)
+ if self.SITE_KEYS:
+ field_keys = list(self.fields.keys())
+ for site_key in list(self.SITE_KEYS.keys()):
+ if site_key in field_keys:
+ self.fields[site_key].label = profile.get_site_label(
+ self.SITE_KEYS[site_key]
+ )
self._post_init()
def _init_type(self, field):
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 247ab4f61..641a9b0a4 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -2274,12 +2274,28 @@ TRANSLATED_SITE_LABELS = {
'new': _(u"New site"),
'modification': _(u"Site modification"),
'deletion': _(u"Site deletion"),
+ "attached-to-operation": _(u"Site (attached to the "
+ u"operation)"),
+ "name-attached-to-operation": _(u"Site name (attached "
+ u"to the operation)"),
+ "attached-to-cr": _(u"Site (attached to the context "
+ u"record)"),
+ "name-attached-to-cr":
+ _(u"Site name (attached to the context record)"),
},
'entity': {
'search': _(u"Archaeological entity search"),
'new': _(u"New archaeological entity"),
'modification': _(u"Archaeological entity modification"),
'deletion': _(u"Archaeological entity deletion"),
+ "attached-to-operation": _(u"Archaeological entity (attached to the "
+ u"operation)"),
+ "name-attached-to-operation": _(u"Archaeological entity name (attached "
+ u"to the operation)"),
+ "attached-to-cr": _(u"Archaeological entity (attached to the context "
+ u"record)"),
+ "name-attached-to-cr":
+ _(u"Archaeological entity name (attached to the context record)"),
},
}