Feature: Generische Seiten-Hilfe (UI.pageInfo), POI Multi-Select, Tagessprüche-DB (SW by-v654)
- UI.pageInfo(): generische Hilfe-Funktion — erstes Öffnen zeigt Info-Banner, danach ? Button oben rechts; CSS-Klassen pinfo-* - Übungen-Seite nutzt UI.pageInfo() als erstes Beispiel - Karte POI: Mehrfachauswahl (außer Giftköder), Kombi-Typen entfernt, type als comma-separated im Backend - daily_quotes Tabelle in DB (346 Einträge via import_quotes.py importiert) - GET /widget/quote — deterministischer Tagesspruch (wechselt täglich)
This commit is contained in:
parent
1fdba57365
commit
9103c7950f
12 changed files with 623 additions and 38 deletions
|
|
@ -279,21 +279,19 @@ class UserPoiIn(BaseModel):
|
|||
|
||||
ALLOWED_TYPES = {
|
||||
'waste_basket', 'drinking_water', 'dog_park',
|
||||
'giftkoeder', # Giftköder-Meldung (Community-Pin mit Radius)
|
||||
'kotbeutel', # Kotbeutelspender
|
||||
'kotbeutel_abfall', # Kotbeutelspender + Mülleimer Kombi
|
||||
'bank', # Sitzbank
|
||||
'bank_kotbeutel', # Sitzbank + Kotbeutelspender
|
||||
'bank_kotbeutel_abfall', # Sitzbank + Kotbeutelspender + Mülleimer
|
||||
'gefahr', # Allgemeine Gefahr / Hinweis
|
||||
'parkplatz', # Hundefreundlicher Parkplatz
|
||||
'treffpunkt', # Treffpunkt für Hundehalter
|
||||
'giftkoeder', # Giftköder (exklusiv, kein Kombi)
|
||||
'kotbeutel', # Kotbeutelspender
|
||||
'bank', # Sitzbank
|
||||
'gefahr', # Allgemeine Gefahr / Hinweis
|
||||
'parkplatz', # Hundefreundlicher Parkplatz
|
||||
'treffpunkt', # Treffpunkt für Hundehalter
|
||||
'sonstiges',
|
||||
}
|
||||
|
||||
@router.post('/user-poi')
|
||||
async def add_user_poi(body: UserPoiIn, user = Depends(get_current_user)):
|
||||
if body.type not in ALLOWED_TYPES:
|
||||
types = [t.strip() for t in body.type.split(',') if t.strip()]
|
||||
if not types or any(t not in ALLOWED_TYPES for t in types):
|
||||
raise HTTPException(400, 'Ungültiger Typ')
|
||||
with db() as conn:
|
||||
row = conn.execute("""
|
||||
|
|
|
|||
|
|
@ -1,13 +1,33 @@
|
|||
"""BAN YARO — Widget-Snapshot Endpoint"""
|
||||
"""BAN YARO — Widget-Snapshot + Tagesspruch Endpoints"""
|
||||
|
||||
import json, random
|
||||
from fastapi import APIRouter, Depends
|
||||
from datetime import date
|
||||
from fastapi import APIRouter, Depends, Query
|
||||
from typing import Optional
|
||||
from database import db
|
||||
from auth import get_current_user
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/quote")
|
||||
async def daily_quote(kategorie: Optional[str] = Query(None)):
|
||||
"""Liefert einen deterministischen Tagesspruch (wechselt täglich)."""
|
||||
day_num = (date.today() - date(2026, 1, 1)).days
|
||||
with db() as conn:
|
||||
if kategorie:
|
||||
rows = conn.execute(
|
||||
"SELECT id, text, autor, kategorie FROM daily_quotes WHERE kategorie=?",
|
||||
(kategorie,)
|
||||
).fetchall()
|
||||
else:
|
||||
rows = conn.execute("SELECT id, text, autor, kategorie FROM daily_quotes").fetchall()
|
||||
if not rows:
|
||||
return {"quote": None}
|
||||
q = rows[day_num % len(rows)]
|
||||
return {"quote": dict(q)}
|
||||
|
||||
|
||||
@router.get("/snapshot")
|
||||
async def widget_snapshot(user=Depends(get_current_user)):
|
||||
"""Liefert kompakte Widget-Daten: Hund, nächste Erinnerung, zufälliges Tagebuchbild."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue