diff options
| author | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-06 23:43:35 -0700 |
|---|---|---|
| committer | Tyler Hoang <tyler@tylerhoang.xyz> | 2026-05-06 23:43:35 -0700 |
| commit | ea6462e928f588c3fbff32e0850298d3ff3dbfb4 (patch) | |
| tree | 251446b62003236d1c99b53e6381fac68bc3f4b8 /routers/about.py | |
| parent | ead38fdb13abb406065cef0743d7e411cb27eaf3 (diff) | |
Add /about page with rating system explanation
Introduces a public-facing /about page that explains the 1-3 star rating rubric with real examples pulled from the diary. Each star tier displays 3 randomly-selected, unique films (deduplicated by title to avoid rewatch duplicates).
Changes:
- New routers/about.py: GET /about queries films by stars, dedupes, randomizes
- New templates/about.html: Page with eyebrow, h1, three tier sections with example film cards, closing philosophy, and View Profile button
- main.py: Import about router, register it, add /about to public_paths in AuthMiddleware
- templates/base.html: Add About nav link after Stats
- templates/profile.html: Add About link to /tyler nav
- templates/login.html: Add About and View Profile buttons in footer, plus "Made with Lumière" repo link
Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
Diffstat (limited to 'routers/about.py')
| -rw-r--r-- | routers/about.py | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/routers/about.py b/routers/about.py new file mode 100644 index 0000000..fe28524 --- /dev/null +++ b/routers/about.py @@ -0,0 +1,43 @@ +import random +from fastapi import APIRouter, Depends, Request +from fastapi.templating import Jinja2Templates +from sqlalchemy.orm import Session + +from database import get_db +from models import Film + +router = APIRouter(tags=["about"]) +templates = Jinja2Templates(directory="templates") + + +@router.get("/about", name="about") +def about(request: Request, db: Session = Depends(get_db)): + films_by_rating = {} + + for stars in (1, 2, 3): + all_films = ( + db.query(Film) + .filter(Film.shelf == "diary", Film.stars == stars) + .all() + ) + + # Deduplicate by title, keeping most recent watch per title + seen_titles = {} + for film in sorted(all_films, key=lambda f: f.date_watched or "", reverse=True): + if film.title not in seen_titles: + seen_titles[film.title] = film + + # Randomize and take up to 3 + unique_films = list(seen_titles.values()) + random.shuffle(unique_films) + films_by_rating[str(stars)] = unique_films[:3] + + return templates.TemplateResponse( + request=request, + name="about.html", + context={ + "request": request, + "active_page": "about", + "films_by_rating": films_by_rating, + }, + ) |
