summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@peacefrogs.net>2013-12-06 00:30:35 +0100
committerÉtienne Loks <etienne.loks@peacefrogs.net>2013-12-06 00:30:35 +0100
commita5128e0791c7cd0db9f3775ff681cbc79160af3a (patch)
tree61fedce75f20d19e2e0419f97b0b702278cacb29
parent4fe7989786ec2a0110b2fb2ad9356d7cc24b18e4 (diff)
downloadIshtar-a5128e0791c7cd0db9f3775ff681cbc79160af3a.tar.bz2
Ishtar-a5128e0791c7cd0db9f3775ff681cbc79160af3a.zip
Better date formatting for ooo file variables
-rw-r--r--archaeological_operations/models.py2
-rw-r--r--example_project/settings.py2
-rw-r--r--ishtar_common/ooo_replace.py7
3 files changed, 9 insertions, 2 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py
index 04ad867fc..125a5d7d1 100644
--- a/archaeological_operations/models.py
+++ b/archaeological_operations/models.py
@@ -416,7 +416,7 @@ class AdministrativeAct(BaseHistorizedItem, OwnPerms, ValueGetter):
filename = ''
if operation and self.operation:
filename = self.operation.associated_filename
- else:
+ elif self.associated_file:
filename = self.associated_file.associated_filename
filename = u"-".join(filename.split('-')[:-1]) # remove date
if self.act_type.code:
diff --git a/example_project/settings.py b/example_project/settings.py
index 1e9051429..753c21a07 100644
--- a/example_project/settings.py
+++ b/example_project/settings.py
@@ -45,6 +45,8 @@ LANGUAGE_CODE = 'fr-fr'
COUNTRY = "fr"
+DATE_FORMAT = u"%-d %B %Y"
+
SITE_ID = 1
# If you set this to False, Django will make some optimizations so as not
diff --git a/ishtar_common/ooo_replace.py b/ishtar_common/ooo_replace.py
index 2158bb473..d929d9359 100644
--- a/ishtar_common/ooo_replace.py
+++ b/ishtar_common/ooo_replace.py
@@ -63,7 +63,12 @@ def _format_value(value, default_value):
c_locale = "_".join(c_locale)
if locale.getlocale()[0] != c_locale:
locale.setlocale(locale.LC_ALL, c_locale)
- value = value.strftime('%x')
+ if settings.DATE_FORMAT:
+ value = unicode(value.strftime(settings.DATE_FORMAT).decode(
+ locale.getlocale()[1]).lower())
+ else:
+ value = unicode(value.strftime('%x').decode(
+ locale.getlocale()[1]))
value = unicode(value) if value else default_value
return value