From 493a56a0f8265be8bafd5474607a9a562dc7caad Mon Sep 17 00:00:00 2001 From: Birger Schacht Date: Tue, 13 Aug 2024 12:18:24 +0200 Subject: [PATCH] chore(deps): bump apis-core-rdf to v0.24.0 ... and adapt the filtersets, to override the new default `search`. Also use the new `_default_search_fields` attribute for models. --- apis_ontology/filtersets.py | 26 ++++++++++++-------------- apis_ontology/models.py | 4 ++++ pyproject.toml | 2 +- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/apis_ontology/filtersets.py b/apis_ontology/filtersets.py index 7786e05..ebcbdd1 100644 --- a/apis_ontology/filtersets.py +++ b/apis_ontology/filtersets.py @@ -81,35 +81,33 @@ class PersonFilterSet(LegacyStuffMixinFilterSet): label="Collections", method=collection_method, ) - search = django_filters.CharFilter( - method=trigram_search_filter_person, - label="Search", - help_text=PERSON_HELP_TEXT) def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.filters.move_to_end("forename", False) self.filters.move_to_end("collection", False) self.filters.move_to_end("search", False) + self.filters["search"] = django_filters.CharFilter( + method=trigram_search_filter_person, + label="Search", + help_text=PERSON_HELP_TEXT) class InstitutionFilterSet(LegacyStuffMixinFilterSet): - search = django_filters.CharFilter( - method=trigram_search_filter_institution, - label="Search", - help_text=HELP_TEXT) - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.filters.move_to_end("search", False) + self.filters["search"] = django_filters.CharFilter( + method=trigram_search_filter_institution, + label="Search", + help_text=HELP_TEXT) class PlaceFilterSet(LegacyStuffMixinFilterSet): - search = django_filters.CharFilter( - method=trigram_search_filter_place, - label="Search", - help_text=HELP_TEXT) - def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.filters.move_to_end("search", False) + self.filters["search"] = django_filters.CharFilter( + method=trigram_search_filter_place, + label="Search", + help_text=HELP_TEXT) diff --git a/apis_ontology/models.py b/apis_ontology/models.py index e41f226..856eb20 100644 --- a/apis_ontology/models.py +++ b/apis_ontology/models.py @@ -100,6 +100,8 @@ class Event(LegacyStuffMixin, VersionMixin, LegacyDateMixin, AbstractEntity): name = models.CharField(max_length=255, verbose_name="Name", blank=True) notes = models.TextField(blank=True, null=True, verbose_name=_("Notes")) + _default_search_fields = ["name", "notes", "kind"] + def __str__(self): return self.name @@ -217,6 +219,8 @@ class Work(LegacyStuffMixin, VersionMixin, LegacyDateMixin, AbstractEntity): name = models.CharField(max_length=255, verbose_name="Name", blank=True) notes = models.TextField(blank=True, null=True, verbose_name=_("Notes")) + _default_search_fields = ["name", "notes", "kind"] + def __str__(self): return self.name diff --git a/pyproject.toml b/pyproject.toml index 7122bc4..2c47f2d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,7 +10,7 @@ packages = [{include = "apis_ontology"}] [tool.poetry.dependencies] python = "^3.11" psycopg2 = "^2.9" -apis-core = {git = "https://github.com/acdh-oeaw/apis-core-rdf", rev = "v0.23.2"} +apis-core = {git = "https://github.com/acdh-oeaw/apis-core-rdf", rev = "v0.24.0"} apis-highlighter-ng = "^0.4.0" apis-acdhch-default-settings = "1.0.0" django-acdhch-functions = "^0.1.3"