v0.8.9: Format email timestamps as 'Tuesday, August 8, 2026 @ 9:24pm' in America/Regina timezone
Add regina_dt Jinja2 template filter that converts UTC ISO-8601 timestamps to America/Regina timezone and formats them as 'Weekday, Month D, YYYY @ H:MMam/pm'. Applied to preview_sent_at and delivery_sent_at on the admin request page.
This commit is contained in:
parent
9575464be2
commit
d4f54bcff5
4 changed files with 23 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
|||
# Theme Song Booth (MusicGPT Edition)
|
||||
|
||||

|
||||

|
||||
|
||||
A Flask web application for running a convention booth where visitors request a custom AI-generated theme song. Operators manage the queue from an admin dashboard, generate prompts via Hermes, queue generations through the MusicGPT API, and deliver final songs by email.
|
||||
|
||||
|
|
|
|||
2
VERSION
2
VERSION
|
|
@ -1 +1 @@
|
|||
0.8.8
|
||||
0.8.9
|
||||
19
app.py
19
app.py
|
|
@ -91,6 +91,25 @@ from helpers import (
|
|||
app = Flask(__name__)
|
||||
app.config.from_object(Config)
|
||||
|
||||
# Template filter: format UTC ISO timestamp as "Tuesday, August 8, 2026 @ 9:24pm" in America/Regina.
|
||||
from datetime import datetime, timezone
|
||||
from zoneinfo import ZoneInfo
|
||||
|
||||
_REGINA_TZ = ZoneInfo("America/Regina")
|
||||
|
||||
@app.template_filter("regina_dt")
|
||||
def regina_dt_filter(value):
|
||||
if not value:
|
||||
return ""
|
||||
try:
|
||||
dt = datetime.fromisoformat(value)
|
||||
if dt.tzinfo is None:
|
||||
dt = dt.replace(tzinfo=timezone.utc)
|
||||
dt = dt.astimezone(_REGINA_TZ)
|
||||
return dt.strftime("%A, %B %-d, %Y @ %-I:%M%p").replace("AM", "am").replace("PM", "pm")
|
||||
except (ValueError, TypeError):
|
||||
return value
|
||||
|
||||
# Global request rate limiting by remote IP (default 60/min). The public form is further limited to 5/min.
|
||||
limiter = Limiter(get_remote_address, app=app, default_limits=["60 per minute"])
|
||||
|
||||
|
|
|
|||
|
|
@ -652,7 +652,7 @@
|
|||
<p>
|
||||
Preview email:
|
||||
{% if req.preview_sent_at %}
|
||||
<span class="status-badge sent">✅ Sent</span> {{ req.preview_sent_at }}
|
||||
<span class="status-badge sent">✅ Sent</span> {{ req.preview_sent_at|regina_dt }}
|
||||
{% else %}
|
||||
<span class="status-badge missing">❌ Not sent yet</span>
|
||||
{% endif %}
|
||||
|
|
@ -685,7 +685,7 @@
|
|||
<p>
|
||||
Delivery email:
|
||||
{% if req.delivery_sent_at %}
|
||||
<span class="status-badge sent">✅ Sent</span> {{ req.delivery_sent_at }}
|
||||
<span class="status-badge sent">✅ Sent</span> {{ req.delivery_sent_at|regina_dt }}
|
||||
{% else %}
|
||||
<span class="status-badge missing">❌ Not sent yet</span>
|
||||
{% endif %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue