From b254b0c4eeb07dba9103f2248ee1e8a53b2265c8 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 14 Jul 2024 10:24:26 -0400 Subject: [PATCH] search title in site preferred locales if not in current locales --- catalog/common/models.py | 9 +++++++-- common/models/__init__.py | 2 ++ journal/views/post.py | 1 - neodb-takahe | 2 +- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/catalog/common/models.py b/catalog/common/models.py index 9a2febfd..5f4cfede 100644 --- a/catalog/common/models.py +++ b/catalog/common/models.py @@ -20,7 +20,12 @@ from ninja import Field, Schema from polymorphic.models import PolymorphicModel from catalog.common import jsondata -from common.models import LANGUAGE_CHOICES, LOCALE_CHOICES, SCRIPT_CHOICES +from common.models import ( + LANGUAGE_CHOICES, + LOCALE_CHOICES, + PREFERRED_LOCALES, + SCRIPT_CHOICES, +) from common.models.lang import get_current_locales from common.models.misc import uniq @@ -597,7 +602,7 @@ class Item(PolymorphicModel): def get_localized_description(self) -> str | None: if self.localized_description: - locales = get_current_locales() + locales = get_current_locales() + PREFERRED_LOCALES for loc in locales: v = next( filter(lambda t: t["lang"] == loc, self.localized_description), {} diff --git a/common/models/__init__.py b/common/models/__init__.py index 20761ae2..ee8c1fe0 100644 --- a/common/models/__init__.py +++ b/common/models/__init__.py @@ -3,6 +3,8 @@ from .lang import ( DEFAULT_CATALOG_LANGUAGE, LANGUAGE_CHOICES, LOCALE_CHOICES, + PREFERRED_LANGUAGES, + PREFERRED_LOCALES, SCRIPT_CHOICES, detect_language, ) diff --git a/journal/views/post.py b/journal/views/post.py index ea5b87a7..79cc1d95 100644 --- a/journal/views/post.py +++ b/journal/views/post.py @@ -69,7 +69,6 @@ def post_boost(request: AuthedHttpRequest, post_id: int): if not post: raise BadRequest(_("Invalid parameter")) boost = Takahe.boost_post(post_id, request.user.identity.pk) - print(boost.state if boost else "x") if boost and boost.state == "new": if request.user.mastodon and request.user.preference.mastodon_repost_mode == 1: request.user.mastodon.boost_later(post.object_uri) diff --git a/neodb-takahe b/neodb-takahe index 005dc7b6..7ea6cb12 160000 --- a/neodb-takahe +++ b/neodb-takahe @@ -1 +1 @@ -Subproject commit 005dc7b61b37ad6f3f4bd2bf4c8b1322a1de8595 +Subproject commit 7ea6cb122ccec55c2d5b6f719bd578f8ac31a322