Merge branch 'main' of https://github.com/neodb-social/neodb
Some checks are pending
code check / lint (3.12) (push) Waiting to run
code check / type-checker (3.12) (push) Waiting to run
Mirror to Codeberg / to_codeberg (push) Waiting to run
unit test / django (3.12) (push) Waiting to run

This commit is contained in:
gesang 2025-03-10 10:31:10 +01:00
commit b0ec90060a
Signed by: gesang
GPG key ID: 6CE35141D31CEAFB
6 changed files with 613 additions and 526 deletions

View file

@ -178,7 +178,11 @@ class JournalSearchResult(SearchResult):
[], [],
) )
) )
items = Item.objects.filter(pk__in=ids, is_deleted=False) select = {f"id_{i}": f"id={i}" for i in ids}
order = [f"-id_{i}" for i in ids]
items = Item.objects.filter(pk__in=ids, is_deleted=False).extra(
select=select, order_by=order
)
items = [j for j in [i.final_item for i in items] if not j.is_deleted] items = [j for j in [i.final_item for i in items] if not j.is_deleted]
return items return items
@ -197,7 +201,9 @@ class JournalSearchResult(SearchResult):
], ],
[], [],
) )
ps = Piece.objects.filter(pk__in=ids) select = {f"id_{i}": f"id={i}" for i in ids}
order = [f"-id_{i}" for i in ids]
ps = Piece.objects.filter(pk__in=ids).extra(select=select, order_by=order)
return ps return ps
@cached_property @cached_property

View file

@ -50,6 +50,10 @@ def html_to_text(h: str) -> str:
) )
def has_spoiler(s: str) -> bool:
return ">!" in s
def _spolier(s: str) -> str: def _spolier(s: str) -> str:
sl = s.split(">!", 1) sl = s.split(">!", 1)
if len(sl) == 1: if len(sl) == 1:

View file

@ -1,7 +1,7 @@
{% load i18n %} {% load i18n %}
<aside class="grid__aside bottom"> <aside class="grid__aside bottom">
<p> <details open>
{% trans 'Addtional filters may be added to query' %} <summary>{% trans 'Search filters' %}</summary>
<li> <li>
<code>status:complete</code> - {% trans 'filter by one of these statuses' %}: <code>wishlist</code> / <code>progress</code> / <code>complete</code> / <code>dropped</code> <code>status:complete</code> - {% trans 'filter by one of these statuses' %}: <code>wishlist</code> / <code>progress</code> / <code>complete</code> / <code>dropped</code>
</li> </li>
@ -29,5 +29,8 @@
<li> <li>
<code>date:2022..2023</code> - {% trans 'filter by date range' %} <code>date:2022..2023</code> - {% trans 'filter by date range' %}
</li> </li>
</p> <li>
<code>sort:date</code> - {% trans "sort by one of these fields" %}: <code>date</code> ({% trans "from new to old" %}) / <code>rating</code> ({% trans "from high to low" %})
</li>
</details>
</aside> </aside>

View file

@ -14,7 +14,7 @@ from django.views.decorators.http import require_http_methods
from catalog.models import * from catalog.models import *
from common.utils import AuthedHttpRequest, get_uuid_or_404 from common.utils import AuthedHttpRequest, get_uuid_or_404
from journal.models.renderers import convert_leading_space_in_md, render_md from journal.models.renderers import convert_leading_space_in_md, has_spoiler, render_md
from users.middlewares import activate_language_for_user from users.middlewares import activate_language_for_user
from users.models.apidentity import APIdentity from users.models.apidentity import APIdentity
@ -135,9 +135,12 @@ class ReviewFeed(Feed):
return reviews return reviews
def item_title(self, item: Review): def item_title(self, item: Review):
return _("{review_title} - a review of {item_title}").format( s = _("{review_title} - a review of {item_title}").format(
review_title=item.title, item_title=item.item.title review_title=item.title, item_title=item.item.title
) )
if has_spoiler(item.body):
s += " (" + _("may contain spoiler or triggering content") + ")"
return s
def item_description(self, item: Review): def item_description(self, item: Review):
target_html = ( target_html = (

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff