diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/forms.py | 14 | ||||
-rw-r--r-- | ishtar_common/models.py | 16 |
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)"), }, } |