summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-23 10:21:53 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-23 10:21:53 +0100
commitf82589a4ad3d6501d4b07afe7b1f39467d355147 (patch)
tree98f6fccc22dc283a84d0271a26546b03b3073d2b
parente019be5389ff31c259c31efe6be3dfe10aa1c62b (diff)
downloadIshtar-f82589a4ad3d6501d4b07afe7b1f39467d355147.tar.bz2
Ishtar-f82589a4ad3d6501d4b07afe7b1f39467d355147.zip
Site labels: fix translation of customization
-rw-r--r--archaeological_context_records/forms.py7
-rw-r--r--archaeological_operations/forms.py4
-rw-r--r--archaeological_operations/models.py1
-rw-r--r--archaeological_operations/views.py6
-rw-r--r--archaeological_operations/wizards.py10
-rw-r--r--ishtar_common/models.py25
6 files changed, 33 insertions, 20 deletions
diff --git a/archaeological_context_records/forms.py b/archaeological_context_records/forms.py
index de44998e6..e776f2ec7 100644
--- a/archaeological_context_records/forms.py
+++ b/archaeological_context_records/forms.py
@@ -150,7 +150,8 @@ class RecordFormGeneral(CustomForm, ManageOldType):
parcel = forms.ChoiceField(label=_("Parcel"), choices=[])
archaeological_site = forms.ChoiceField(
label=" ", choices=[], required=False,
- help_text=_(u"Only the items associated to the operation can be selected.")
+ help_text=_(u"Only the items associated to the operation can be "
+ u"selected.")
)
label = forms.CharField(label=_(u"ID"),
validators=[validators.MaxLengthValidator(200)])
@@ -233,10 +234,6 @@ class RecordFormGeneral(CustomForm, ManageOldType):
site_label = IshtarSiteProfile.get_default_site_label()
self.fields['archaeological_site'].label = site_label
- self.fields['archaeological_site'].help_text = \
- unicode(self.fields['archaeological_site'].help_text).format(
- site_label
- )
self.fields['archaeological_site'].choices = [('', '--')]
if operation:
diff --git a/archaeological_operations/forms.py b/archaeological_operations/forms.py
index c51616e21..e0d31bef7 100644
--- a/archaeological_operations/forms.py
+++ b/archaeological_operations/forms.py
@@ -1277,9 +1277,7 @@ class SiteFormSelection(IshtarForm):
@classmethod
def form_label(cls):
- return unicode(_(u"{} search")).format(
- get_current_profile().get_site_label()
- )
+ return get_current_profile().get_site_label('search')
def clean(self):
cleaned_data = self.cleaned_data
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 7d0efe34c..035c98190 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -1566,6 +1566,7 @@ def parcel_post_save(sender, **kwargs):
# parcels are copied between files and operations
parcel.copy_to_operation()
+
post_save.connect(parcel_post_save, sender=Parcel)
diff --git a/archaeological_operations/views.py b/archaeological_operations/views.py
index 054963f09..55c688854 100644
--- a/archaeological_operations/views.py
+++ b/archaeological_operations/views.py
@@ -345,8 +345,8 @@ show_site = show_item(
site_search_wizard = SiteSearch.as_view(
[('general-site_search', SiteFormSelection)],
- label=_(u"{} search"),
- url_name='site_search',)
+ url_name='site_search',
+)
site_creation_steps = [
@@ -357,7 +357,6 @@ site_creation_steps = [
site_creation_wizard = SiteWizard.as_view(
site_creation_steps,
- label=_(u"New {}"),
url_name='site_creation',
)
@@ -370,7 +369,6 @@ site_modification_steps = [
site_modification_wizard = SiteModificationWizard.as_view(
site_modification_steps,
- label=_(u"{} modification"),
url_name='site_modification',
)
diff --git a/archaeological_operations/wizards.py b/archaeological_operations/wizards.py
index 18c4b20e8..dc96da7be 100644
--- a/archaeological_operations/wizards.py
+++ b/archaeological_operations/wizards.py
@@ -453,21 +453,23 @@ class OperationEditAdministrativeActWizard(OperationAdministrativeActWizard):
class SiteLabel(object):
+ SITE_KEY = ""
+
def get_label(self):
- return unicode(_(u"Search {}")).format(
- get_current_profile().get_site_label()
- )
+ return get_current_profile().get_site_label(self.SITE_KEY)
class SiteSearch(SiteLabel, SearchWizard):
- pass
+ SITE_KEY = "search"
class SiteWizard(SiteLabel, Wizard):
+ SITE_KEY = 'new'
model = models.ArchaeologicalSite
class SiteModificationWizard(SiteWizard):
+ SITE_KEY = 'modification'
modification = True
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index e33fb73e4..7798c722d 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -1478,6 +1478,19 @@ FIND_INDEX_SOURCE = ((u"O", _(u"Operations")),
(u"CR", _(u"Context records")))
SITE_LABELS = [('site', _(u"Site")), ('entity', _(u"Archaeological site"))]
+TRANSLATED_SITE_LABELS = {
+ 'site': {
+ 'search': _(u"Site search"),
+ 'new': _(u"New site"),
+ 'modification': _(u"Site modification"),
+ },
+ 'entity': {
+ 'search': _(u"Archaeological site search"),
+ 'new': _(u"New archaeological site"),
+ 'modification': _(u"Archaeological site modification"),
+ },
+}
+
class IshtarSiteProfile(models.Model, Cached):
slug_field = 'slug'
@@ -1596,11 +1609,15 @@ class IshtarSiteProfile(models.Model, Cached):
return obj
@classmethod
- def get_default_site_label(cls):
- return cls.get_current_profile().get_site_label()
+ def get_default_site_label(cls, key=None):
+ return cls.get_current_profile().get_site_label(key)
- def get_site_label(self):
- return unicode(dict(SITE_LABELS)[self.archaeological_site_label])
+ def get_site_label(self, key=None):
+ if not key:
+ return unicode(dict(SITE_LABELS)[self.archaeological_site_label])
+ return unicode(
+ TRANSLATED_SITE_LABELS[self.archaeological_site_label][key]
+ )
def save(self, *args, **kwargs):
raw = False