From 2b46f7d3dc32736f62746acf38147c0a6c0eff53 Mon Sep 17 00:00:00 2001 From: "Troll (Hermes Agent)" Date: Wed, 5 Aug 2026 03:11:21 +0000 Subject: [PATCH] Guard customer_approved null/None in all templates Some rows (schema drift, cancelled requests, manual status edits) have customer_approved = NULL instead of the default 'none'. Templates called .upper() on it blindly, causing a Jinja2 UndefinedError / 500 when the customer player or admin pages loaded. Replace all .upper() calls with (value or 'none').upper() and add truthy checks before rendering the approved choice in status.html and dashboard.html. --- templates/admin/dashboard.html | 2 +- templates/admin/request.html | 2 +- templates/admin/sales.html | 2 +- templates/player.html | 2 +- templates/status.html | 4 ++-- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/templates/admin/dashboard.html b/templates/admin/dashboard.html index 398a360..5dbaf78 100644 --- a/templates/admin/dashboard.html +++ b/templates/admin/dashboard.html @@ -164,7 +164,7 @@ {{ r.email }} {{ r.style_genre or '-' }} {{ statuses[r.status] }} - {% if r.customer_approved != 'none' %}{{ r.customer_approved.upper() }}{% else %}-{% endif %} + {% if r.customer_approved and r.customer_approved != 'none' %}{{ (r.customer_approved or 'none').upper() }}{% else %}-{% endif %} Open
diff --git a/templates/admin/request.html b/templates/admin/request.html index f6bd995..63fe269 100644 --- a/templates/admin/request.html +++ b/templates/admin/request.html @@ -348,7 +348,7 @@ {% if req.customer_approved == 'none' %} Nothing yet {% else %} - {{ req.customer_approved.upper() }} + {{ (req.customer_approved or 'none').upper() }} {% endif %}

diff --git a/templates/admin/sales.html b/templates/admin/sales.html index 6a7b642..5759f4c 100644 --- a/templates/admin/sales.html +++ b/templates/admin/sales.html @@ -58,7 +58,7 @@ #{{ s.id }} {{ s.name }} {{ s.email }} - {% if s.customer_approved == 'both' %}Both Versions{% else %}Version {{ s.customer_approved.upper() }}{% endif %} + {% if s.customer_approved == 'both' %}Both Versions{% else %}Version {{ (s.customer_approved or 'none').upper() }}{% endif %} {{ s.square_payment_ref or '-' }} {% endfor %} diff --git a/templates/player.html b/templates/player.html index f616542..78e1c2a 100644 --- a/templates/player.html +++ b/templates/player.html @@ -160,7 +160,7 @@

✅ Choice Received

-

You selected: {% if req.customer_approved == 'both' %}Both Versions{% else %}Version {{ req.customer_approved.upper() }}{% endif %}

+

You selected: {% if req.customer_approved == 'both' %}Both Versions{% else %}Version {{ (req.customer_approved or 'none').upper() }}{% endif %}

{% if req.status == 'awaiting_payment' %}

Please return to the booth to finalize payment and collect your files.

{% elif req.status == 'paid' %} diff --git a/templates/status.html b/templates/status.html index b673a66..0022f67 100644 --- a/templates/status.html +++ b/templates/status.html @@ -168,8 +168,8 @@

Request #{{ req.id }} — {{ req.name }}

Status: {{ statuses[req.status] }}

- {% if req.customer_approved != 'none' %} -

You selected: {% if req.customer_approved == 'both' %}Both Versions{% else %}Version {{ req.customer_approved.upper() }}{% endif %}

+ {% if req.customer_approved and req.customer_approved != 'none' %} +

You selected: {% if req.customer_approved == 'both' %}Both Versions{% else %}Version {{ (req.customer_approved or 'none').upper() }}{% endif %}

{% endif %} {% if req.song_a_path and req.song_b_path %}