From eb689cd9a1d9d591036f359c522c32b5893bc132 Mon Sep 17 00:00:00 2001 From: archeious Date: Fri, 17 Apr 2026 16:58:14 -0600 Subject: [PATCH] feat(ui): pretty_year_month helper, render month names in titles pretty_year_month('2026-04') -> 'April 2026' for display. The templates fall back to the raw year_month slug when the helper returns nothing. Used by month.html and month_create.html to give the nav a broadsheet feel; the URL routes still use the YYYY-MM slug everywhere. Refs #17 Co-Authored-By: Claude Opus 4.7 (1M context) --- src/quartermaster/month_service.py | 13 +++++++++++++ src/quartermaster/routes_month.py | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/quartermaster/month_service.py b/src/quartermaster/month_service.py index 9ecc0b9..097adb1 100644 --- a/src/quartermaster/month_service.py +++ b/src/quartermaster/month_service.py @@ -83,6 +83,19 @@ def shift_year_month(year_month: str, delta: int) -> str: return f"{new_year:04d}-{new_month0 + 1:02d}" +_MONTH_NAMES = [ + "", "January", "February", "March", "April", "May", "June", + "July", "August", "September", "October", "November", "December", +] + + +def pretty_year_month(year_month: str) -> str: + if not valid_year_month(year_month): + return year_month + year, month = year_month.split("-") + return f"{_MONTH_NAMES[int(month)]} {year}" + + def get_month(db: Session, year_month: str) -> Month | None: stmt = select(Month).where(Month.year_month == year_month) return db.scalar(stmt) diff --git a/src/quartermaster/routes_month.py b/src/quartermaster/routes_month.py index 729dee6..e64fc75 100644 --- a/src/quartermaster/routes_month.py +++ b/src/quartermaster/routes_month.py @@ -131,6 +131,9 @@ def view_month( "month_create.html", { "year_month": year_month, + "pretty_year_month": month_service.pretty_year_month(year_month), + "pretty_prev": month_service.pretty_year_month(prev_ym), + "pretty_next": month_service.pretty_year_month(next_ym), "prev_year_month": prev_ym, "next_year_month": next_ym, "all_months": all_months, @@ -148,6 +151,9 @@ def view_month( { "month": month, "year_month": year_month, + "pretty_year_month": month_service.pretty_year_month(year_month), + "pretty_prev": month_service.pretty_year_month(prev_ym), + "pretty_next": month_service.pretty_year_month(next_ym), "prev_year_month": prev_ym, "next_year_month": next_ym, "all_months": all_months,