summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--archaeological_context_records/forms.py1
-rw-r--r--archaeological_finds/forms.py7
-rw-r--r--archaeological_operations/forms.py2
-rw-r--r--archaeological_warehouse/forms.py6
-rw-r--r--ishtar_common/forms.py14
-rw-r--r--ishtar_common/models.py16
6 files changed, 44 insertions, 2 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index 187a4eb2b..a14fb02d8 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -98,6 +98,7 @@ class RecordSelect(HistorySelect):
FieldType('cr_relation_types', models.RelationType),
FieldType('ope_relation_types', OpeRelationType),
]
+ SITE_KEYS = {"archaeological_site": None}
def get_input_ids(self):
ids = super(RecordSelect, self).get_input_ids()
diff --git a/archaeological_finds/forms.py b/archaeological_finds/forms.py
index fce2fe3d6..6bd89aa48 100644
--- a/archaeological_finds/forms.py
+++ b/archaeological_finds/forms.py
@@ -1087,7 +1087,6 @@ class FindSelect(HistorySelect):
choices=[], label=_(u"Treatment emergency")
)
-
estimated_value__higher = FloatField(
label=_(u"Estimated value - higher than"))
estimated_value__lower = FloatField(
@@ -1127,6 +1126,12 @@ class FindSelect(HistorySelect):
FieldType('alteration_causes', models.AlterationCauseType),
FieldType('treatment_emergency', models.TreatmentEmergencyType),
]
+ SITE_KEYS = {
+ "archaeological_sites": "attached-to-operation",
+ "archaeological_sites_name": "name-attached-to-operation",
+ "archaeological_sites_context_record": "attached-to-cr",
+ "archaeological_sites_context_record_name": "name-attached-to-cr",
+ }
def __init__(self, *args, **kwargs):
super(FindSelect, self).__init__(*args, **kwargs)
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index 88c3b30d4..b1c02779a 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -577,6 +577,7 @@ class OperationSelect(HistorySelect):
FieldType('record_quality_type', models.RecordQualityType),
FieldType('relation_types', models.RelationType),
]
+ SITE_KEYS = {"archaeological_sites": None}
def __init__(self, *args, **kwargs):
super(OperationSelect, self).__init__(*args, **kwargs)
@@ -1258,6 +1259,7 @@ class ArchaeologicalSiteBasicForm(IshtarForm):
new=True),
validators=[valid_id(models.ArchaeologicalSite)],
required=False)
+ SITE_KEYS = {"archaeological_site": None}
ArchaeologicalSiteFormSet = formset_factory(
diff --git a/archaeological_warehouse/forms.py b/archaeological_warehouse/forms.py
index 4550970c9..99855bf0b 100644
--- a/archaeological_warehouse/forms.py
+++ b/archaeological_warehouse/forms.py
@@ -351,6 +351,12 @@ class ContainerSelect(HistorySelect):
FieldType('treatment_emergency', TreatmentEmergencyType),
FieldType('container_type', models.ContainerType)
]
+ SITE_KEYS = {
+ "archaeological_sites": "attached-to-operation",
+ "archaeological_sites_name": "name-attached-to-operation",
+ "archaeological_sites_context_record": "attached-to-cr",
+ "archaeological_sites_context_record_name": "name-attached-to-cr",
+ }
ContainerFormSelection = get_form_selection(
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)"),
},
}