diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-11-02 16:03:26 +0100 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2022-12-12 12:23:19 +0100 | 
| commit | e131856e48cc4644443c62f3f826fa451cb7e66b (patch) | |
| tree | 5888b277c026e0c6e9209472f016055ba73d77c4 /ishtar_common/models_common.py | |
| parent | ad0c40ca519ec3d81120744e6c511fb3d5992897 (diff) | |
| download | Ishtar-e131856e48cc4644443c62f3f826fa451cb7e66b.tar.bz2 Ishtar-e131856e48cc4644443c62f3f826fa451cb7e66b.zip | |
Geodata - search: add search fields on related items searches
Diffstat (limited to 'ishtar_common/models_common.py')
| -rw-r--r-- | ishtar_common/models_common.py | 25 | 
1 files changed, 25 insertions, 0 deletions
| diff --git a/ishtar_common/models_common.py b/ishtar_common/models_common.py index 1c77d1a90..779af635b 100644 --- a/ishtar_common/models_common.py +++ b/ishtar_common/models_common.py @@ -2687,6 +2687,31 @@ class GeographicItem(models.Model):      geodata = models.ManyToManyField(          GeoVectorData, blank=True, related_name="related_items_%(app_label)s_%(class)s"      ) +    ALT_NAMES = { +        "geodata__name": SearchAltName( +            pgettext_lazy("key for text search", "geo-name"), "geodata__name__iexact" +        ), +        "geodata__data_type": SearchAltName( +            pgettext_lazy("key for text search", "geo-type"), "geodata__data_type__label__iexact" +        ), +        "geodata__origin": SearchAltName( +            pgettext_lazy("key for text search", "geo-origin"), "geodata__origin__label__iexact" +        ), +        "geodata__provider": SearchAltName( +            pgettext_lazy("key for text search", "geo-provider"), "geodata__provider__label__iexact" +        ), +        "geodata__comment": SearchAltName( +            pgettext_lazy("key for text search", "geo-comment"), "geodata__comment__iexact" +        ), +    } + +    @classmethod +    def ALT_NAMES_FOR_FIND(cls): +        dct = {} +        for k in cls.ALT_NAMES: +            sa = cls.ALT_NAMES[k] +            dct[k] = SearchAltName(sa.search_key, "base_finds__" + sa.search_query) +        return dct      class Meta:          abstract = True | 
