diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-07-04 15:39:22 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2018-08-13 18:26:03 +0200 | 
| commit | f815706079b41d9216b2f8b8a4db59e0dfdb3cbc (patch) | |
| tree | fef3c93ea1e8c957e14f0e0e8e8f86bb5e221c30 /archaeological_operations/models.py | |
| parent | f67013b0df3016de6d7a090dcb4aa145f003c65c (diff) | |
| download | Ishtar-f815706079b41d9216b2f8b8a4db59e0dfdb3cbc.tar.bz2 Ishtar-f815706079b41d9216b2f8b8a4db59e0dfdb3cbc.zip  | |
Search: manage post process tretment of query (refs #4180)
Diffstat (limited to 'archaeological_operations/models.py')
| -rw-r--r-- | archaeological_operations/models.py | 20 | 
1 files changed, 20 insertions, 0 deletions
diff --git a/archaeological_operations/models.py b/archaeological_operations/models.py index 9565bf144..b929677b8 100644 --- a/archaeological_operations/models.py +++ b/archaeological_operations/models.py @@ -396,10 +396,20 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,              ),              'towns__cached_label__iexact'          ), +        'towns__numero_insee__startswith': ( +            pgettext_lazy( +                "key for text search (no accent, no spaces)", u"department" +            ), +            'towns__numero_insee__startswith' +        )      }      for v in ALT_NAMES.values():          EXTRA_REQUEST_KEYS[v[0]] = v[1] +    POST_PROCESS_REQUEST = { +        'towns__numero_insee__startswith': '_get_department_code', +    } +      # fields definition      creation_date = models.DateField(_(u"Creation date"),                                       default=datetime.date.today) @@ -567,6 +577,16 @@ class Operation(ClosedItem, BaseHistorizedItem, OwnPerms, ValueGetter,          values = super(Operation, self).get_values(prefix=prefix)          return get_values_town_related(self, prefix, values) +    @classmethod +    def _get_department_code(cls, value): +        if not settings.ISHTAR_DPTS: +            return u"" +        for k, v in settings.ISHTAR_DPTS: +            if v.lower() == value: +                return k +        return u"" + +      @property      def short_class_name(self):          return _(u"OPE")  | 
