feat: gestion événements — historique, export ZIP, filtre galerie
🚀 Deploy — JH Photomaton / 🔍 Vérification (push) Has been cancelled
🚀 Deploy — JH Photomaton / 🍓 Deploy sur le Pi (push) Has been cancelled

This commit is contained in:
2026-07-17 14:43:05 +02:00
parent 7d60eba86d
commit d5f111d60b
10 changed files with 329 additions and 117 deletions
+26
View File
@@ -34,12 +34,37 @@ async def api_gallery_photos(
request: Request,
page: int = Query(default=1, ge=1),
limit: int = Query(default=24, ge=1, le=100),
event_slug: str = Query(default=None, description="Filtrer par slug d'événement"),
):
pb = request.app.state.photobooth_service
cfg = request.app.state.config
all_photos = await pb.get_media_collection(limit=500)
photos = [p for p in all_photos if _is_image(p)]
# Filtre par événement si demandé
if event_slug:
from pathlib import Path
from datetime import datetime
event_svc = getattr(request.app.state, "event_service", None)
if event_svc:
ev = await event_svc.get_event_by_slug(event_slug)
if ev:
started_at = ev["started_at"] or 0.0
ended_at = ev["ended_at"] or datetime.now().timestamp()
media_dir = Path(cfg.photobooth.media_dir)
# Construire un index mtime par nom de fichier
mtime_index: dict[str, float] = {}
if media_dir.exists():
for f in media_dir.iterdir():
mtime_index[f.name] = f.stat().st_mtime
# Filtrer les photos par mtime
def _in_event(p: dict) -> bool:
pid = _get_id(p)
mtime = mtime_index.get(pid, mtime_index.get(pid + ".jpg", 0.0))
return started_at <= mtime <= ended_at
photos = [p for p in photos if _in_event(p)]
total = len(photos)
start = (page - 1) * limit
end = start + limit
@@ -56,6 +81,7 @@ async def api_gallery_photos(
"total": total,
"page": page,
"pages": max(1, (total + limit - 1) // limit),
"event_slug": event_slug,
}