search title in site preferred locales if not in current locales

This commit is contained in:
Your Name 2024-07-14 10:24:26 -04:00 committed by Henri Dickson
parent 738cfc20ad
commit b254b0c4ee
4 changed files with 10 additions and 4 deletions

View file

@ -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), {}

View file

@ -3,6 +3,8 @@ from .lang import (
DEFAULT_CATALOG_LANGUAGE,
LANGUAGE_CHOICES,
LOCALE_CHOICES,
PREFERRED_LANGUAGES,
PREFERRED_LOCALES,
SCRIPT_CHOICES,
detect_language,
)

View file

@ -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)

@ -1 +1 @@
Subproject commit 005dc7b61b37ad6f3f4bd2bf4c8b1322a1de8595
Subproject commit 7ea6cb122ccec55c2d5b6f719bd578f8ac31a322