diff options
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") |