diff options
| -rw-r--r-- | ishtar_common/locale/fr/LC_MESSAGES/django.po | 4 | ||||
| -rw-r--r-- | ishtar_common/models.py | 5 | ||||
| -rw-r--r-- | ishtar_common/ooo_replace.py | 27 | 
3 files changed, 25 insertions, 11 deletions
| diff --git a/ishtar_common/locale/fr/LC_MESSAGES/django.po b/ishtar_common/locale/fr/LC_MESSAGES/django.po index f6da52ee3..26b3ea600 100644 --- a/ishtar_common/locale/fr/LC_MESSAGES/django.po +++ b/ishtar_common/locale/fr/LC_MESSAGES/django.po @@ -383,7 +383,7 @@ msgstr "Types d'individu"  #: models.py:658  msgid "Mr" -msgstr "M" +msgstr "M."  #: models.py:659  msgid "Miss" @@ -395,7 +395,7 @@ msgstr "Mme"  #: models.py:661  msgid "Doctor" -msgstr "Dr" +msgstr "Dr."  #: models.py:670 models.py:691  msgid "Types" diff --git a/ishtar_common/models.py b/ishtar_common/models.py index 8d153f120..7777d7d77 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -743,6 +743,11 @@ class Person(Address, OwnPerms, ValueGetter) :                                 if getattr(self, attr)]          return u" ".join(values) +    def get_values(self, prefix=''): +        values = super(Person, self).get_values(prefix=prefix) +        values[prefix+'title'] = dict(self.TYPE)[self.title] +        return values +      person_types_list_lbl = _(u"Types")      @property      def person_types_list(self): diff --git a/ishtar_common/ooo_replace.py b/ishtar_common/ooo_replace.py index 63b983b7b..2158bb473 100644 --- a/ishtar_common/ooo_replace.py +++ b/ishtar_common/ooo_replace.py @@ -17,26 +17,28 @@  # See the file COPYING for details. - +import locale  from zipfile import ZipFile, ZIP_DEFLATED  from cStringIO import StringIO  from xml.etree.cElementTree import ElementTree, fromstring +from django.conf import settings +  OOO_NS = "{urn:oasis:names:tc:opendocument:xmlns:text:1.0}" -def _set_value_from_formula(value, context): +def _set_value_from_formula(value, context, default_value):      value = value.strip()      if value.startswith("ooow:") and len(value) >= 5:          value = value[5:]      if value.startswith('"') and value.endswith('"') and len(value) > 1:          value = value[1:-1]      elif value in context: -        value = unicode(context[value]) +        value = _format_value(context[value], default_value)      else:          value = None      return value -def _parse_condition(condition, context): +def _parse_condition(condition, context, default_value):      # parse only == and != operator      operator = ""      if "!=" in condition: @@ -46,17 +48,23 @@ def _parse_condition(condition, context):      else:          return      var1, var2 = condition.split(operator) -    var1 = _set_value_from_formula(var1, context) -    var2 = _set_value_from_formula(var2, context) +    var1 = _set_value_from_formula(var1, context, default_value) +    var2 = _set_value_from_formula(var2, context, default_value)      res = var1 == var2      if operator == '!=':          res = not res      return res  def _format_value(value, default_value): +    if hasattr(value, 'strftime'): +        c_locale = settings.LANGUAGE_CODE.split('-') +        if len(c_locale) == 2: +            c_locale[1] = c_locale[1].upper() +        c_locale = "_".join(c_locale) +        if locale.getlocale()[0] != c_locale: +            locale.setlocale(locale.LC_ALL, c_locale) +        value = value.strftime('%x')      value = unicode(value) if value else default_value -    #if hasattr(value, 'strftime'): -    #    value = value.strftime()      return value  def ooo_replace(infile, outfile, context, default_value=''): @@ -76,7 +84,8 @@ def ooo_replace(infile, outfile, context, default_value=''):                  missing_keys.add(name)      for p in content.findall(".//"+OOO_NS+"conditional-text"):          condition = p.get(OOO_NS+"condition") -        res = 'true' if _parse_condition(condition, context) else 'false' +        res = 'true' if _parse_condition(condition, context, default_value) \ +              else 'false'          value = p.get(OOO_NS+'string-value-if-' + res)          value = _format_value(value, default_value)          if value.strip() in context: | 
