BGG: Powered-by-Logo im Footer (Lizenzpflicht) + Erscheinungsjahr-Filter (Standard aktuelles Jahr+)

This commit is contained in:
Flo Hartmann
2026-08-25 12:11:06 +00:00
parent 667196a4ba
commit ca6d94938c
8 changed files with 69 additions and 4 deletions

View File

@@ -94,6 +94,7 @@ class NeuheitenPlugin(BasePlugin):
user: User = Depends(require_user),
q: str = "",
status: str = "",
jahr: int | None = None,
sort: str = STANDARD_SORTIERUNG[0],
richtung: str = STANDARD_SORTIERUNG[1],
meldung: str = "",
@@ -118,6 +119,26 @@ class NeuheitenPlugin(BasePlugin):
)
if status.strip():
abfrage = abfrage.where(Neuheit.status == status.strip())
# Erscheinungsjahr-Filter: Standard „aktuelles Jahr und neuer“.
jahr_standard = datetime.now(timezone.utc).year
if jahr is None:
jahr_filter = jahr_standard
abfrage = abfrage.where(
or_(
Neuheit.erscheinungsjahr >= jahr_standard,
Neuheit.erscheinungsjahr.is_(None), # ohne Jahr nicht wegfiltern
)
)
else:
jahr_filter = jahr
abfrage = abfrage.where(Neuheit.erscheinungsjahr >= jahr)
jahr_optionen = [
j for j in db.scalars(
select(Neuheit.erscheinungsjahr).distinct().order_by(
Neuheit.erscheinungsjahr.desc()
)
) if j is not None
]
gesamt = db.scalar(select(func.count()).select_from(abfrage.subquery())) or 0
eintraege = db.scalars(
abfrage.order_by(spalte_sortiert, Neuheit.id.asc())
@@ -138,6 +159,9 @@ class NeuheitenPlugin(BasePlugin):
"eintraege": eintraege,
"q": q,
"status_filter": status,
"jahr_filter": jahr_filter,
"jahr_standard": jahr_standard,
"jahr_optionen": jahr_optionen,
"sort": sort if sort in SORTIERBAR else STANDARD_SORTIERUNG[0],
"richtung": "ab" if abwaerts else "auf",
"status_optionen": status_optionen,

View File

@@ -121,7 +121,7 @@
<form method="get" action="/neuheiten"
hx-get="/neuheiten" hx-target="#neuheiten-liste" hx-swap="outerHTML"
hx-trigger="input changed delay:300ms from:find input[name='q'], change from:find select[name='status']"
hx-trigger="input changed delay:300ms from:find input[name='q'], change from:find select[name='status'], change from:find select[name='jahr']"
class="grid grid-cols-1 sm:flex sm:flex-wrap gap-3 mb-4">
<input type="text" name="q" value="{{ q }}" placeholder="Suche in Titel, Verlag, Autor …"
class="w-full min-h-[44px] border border-slate-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-emerald-500 sm:w-80">
@@ -131,6 +131,13 @@
<option value="{{ option }}" {% if option == status_filter %}selected{% endif %}>{{ option }}</option>
{% endfor %}
</select>
<select name="jahr" class="w-full sm:w-auto min-h-[44px] md:min-h-0 border border-slate-300 rounded-lg px-3 py-2 text-sm bg-white">
<option value="{{ jahr_standard }}">ab {{ jahr_standard }}</option>
{% for jahr in jahr_optionen %}
<option value="{{ jahr }}" {% if jahr|string == jahr_filter|string %}selected{% endif %}>{{ jahr }}</option>
{% endfor %}
<option value="" {% if not jahr_filter %}selected{% endif %}>Alle Jahre</option>
</select>
<noscript>
<button type="submit" class="bg-slate-200 hover:bg-slate-300 px-4 py-2 rounded-lg text-sm min-h-[44px] md:min-h-0">Filtern</button>
</noscript>