From e131856e48cc4644443c62f3f826fa451cb7e66b Mon Sep 17 00:00:00 2001 From: Étienne Loks Date: Wed, 2 Nov 2022 16:03:26 +0100 Subject: Geodata - search: add search fields on related items searches --- ishtar_common/models_common.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'ishtar_common/models_common.py') 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 -- cgit v1.2.3