diff --git a/src/onegov/directory/models/directory_entry.py b/src/onegov/directory/models/directory_entry.py index 61c0d9b9a0..4f92fe3828 100644 --- a/src/onegov/directory/models/directory_entry.py +++ b/src/onegov/directory/models/directory_entry.py @@ -1,5 +1,3 @@ -from sqlalchemy.ext.hybrid import hybrid_property - from onegov.core.orm import Base from onegov.core.orm.mixins import ContentMixin from onegov.core.orm.mixins import TimestampMixin @@ -100,7 +98,7 @@ def keywords(self): def keywords(self, value): self._keywords = {k: '' for k in value} if value else None - @hybrid_property + @property def text(self): return self.directory.configuration.extract_searchable(self.values) diff --git a/src/onegov/feriennet/models/activity.py b/src/onegov/feriennet/models/activity.py index e029aa6196..b959a46c91 100644 --- a/src/onegov/feriennet/models/activity.py +++ b/src/onegov/feriennet/models/activity.py @@ -1,7 +1,5 @@ from functools import cached_property -from sqlalchemy.ext.hybrid import hybrid_property - from onegov.activity import Activity, ActivityCollection, Occasion from onegov.activity import PublicationRequestCollection from onegov.activity.models import DAYS @@ -39,7 +37,7 @@ def es_public(self): def es_skip(self): return self.state == 'preview' - @hybrid_property + @property def organiser(self): organiser = [ self.user.username, diff --git a/src/onegov/fsi/models/course_attendee.py b/src/onegov/fsi/models/course_attendee.py index ceaee8127c..5a243ed852 100644 --- a/src/onegov/fsi/models/course_attendee.py +++ b/src/onegov/fsi/models/course_attendee.py @@ -1,5 +1,3 @@ -from sqlalchemy.ext.hybrid import hybrid_property - from onegov.core.orm import Base from onegov.core.orm.types import UUID, JSON from sqlalchemy import Boolean @@ -109,7 +107,7 @@ def __str__(self): cascade='all, delete-orphan' ) - @hybrid_property + @property def title(self): return ' '.join(( p for p in ( @@ -133,7 +131,7 @@ def role(self): return 'member' return self.user.role - @hybrid_property + @property def email(self): """Needs a switch for external users""" if not self.user_id: diff --git a/src/onegov/fsi/models/course_event.py b/src/onegov/fsi/models/course_event.py index 020c48a0d1..aeb8ec908b 100644 --- a/src/onegov/fsi/models/course_event.py +++ b/src/onegov/fsi/models/course_event.py @@ -85,7 +85,7 @@ def es_public(self): def title(self): return str(self) - @hybrid_property + @property def name(self): return self.course.name @@ -97,7 +97,7 @@ def lead(self): f'{self.presenter_company}' ) - @hybrid_property + @property def description(self): return self.course.description diff --git a/src/onegov/search/mixins.py b/src/onegov/search/mixins.py index b1f2b644fc..28c16c0e7b 100644 --- a/src/onegov/search/mixins.py +++ b/src/onegov/search/mixins.py @@ -4,8 +4,9 @@ from sqlalchemy.orm import deferred from onegov.core.upgrade import UpgradeContext -from onegov.search.utils import classproperty, \ - get_fts_index_localized_languages, get_fts_index_basic_languages +from onegov.search.utils import (classproperty, + get_fts_index_localized_languages, + get_fts_index_basic_languages) from onegov.search.utils import extract_hashtags from typing import Any, TYPE_CHECKING @@ -227,7 +228,7 @@ def add_fts_column(request, model): prop = getattr(model, prop_name) languages = get_fts_index_basic_languages() - if prop_type in ['localized', 'localized_html']: + if prop_type.startswith('localized'): # only for 'localized' properties we create the # index localized languages.extend(get_fts_index_localized_languages()) diff --git a/src/onegov/search/utils.py b/src/onegov/search/utils.py index 1457251f58..041ca6f0d7 100644 --- a/src/onegov/search/utils.py +++ b/src/onegov/search/utils.py @@ -39,6 +39,14 @@ def get_fts_index_languages(): return ['simple', 'german', 'french', 'italian', 'english'] +def get_fts_index_basic_languages(): + return ['simple', 'german'] + + +def get_fts_index_localized_languages(): + return ['french', 'italian', 'english'] + + def is_valid_index_name(name): """ Checks if the given name is a valid elasticsearch index name. Elasticsearch does it's own checks, but we can do it earlier and we are diff --git a/src/onegov/ticket/model.py b/src/onegov/ticket/model.py index 4ed43200ad..4c4c0ed5f6 100644 --- a/src/onegov/ticket/model.py +++ b/src/onegov/ticket/model.py @@ -1,5 +1,3 @@ -from sqlalchemy.ext.hybrid import hybrid_property - from onegov.core.orm import Base from onegov.core.orm.mixins import TimestampMixin from onegov.core.orm.types import JSON, UUID @@ -159,7 +157,7 @@ def created(cls) -> 'Column[datetime]': 'extra_localized_text': {'type': 'localized'} } - @hybrid_property + @property def extra_localized_text(self) -> str | None: """ Maybe used by child-classes to return localized extra data that should be indexed as well. @@ -174,14 +172,14 @@ def es_suggestion(self) -> list[str]: self.number.replace('-', '') ] - @hybrid_property + @property def ticket_email(self) -> str | None: if self.handler.deleted: return self.snapshot.get('email') else: return self.handler.email - @hybrid_property + @property def ticket_data(self) -> 'Sequence[str] | None': if self.handler.deleted: return self.snapshot.get('summary') diff --git a/src/onegov/user/models/user.py b/src/onegov/user/models/user.py index 93e7b29abe..130de2a5a2 100644 --- a/src/onegov/user/models/user.py +++ b/src/onegov/user/models/user.py @@ -58,7 +58,7 @@ class User(Base, TimestampMixin, ORMSearchable): def es_suggestion(self) -> tuple[str, str]: return (self.realname or self.username, self.username) - @hybrid_property + @property def userprofile(self) -> list[str]: if not self.data: return []