Color-code drink buttons by category

Add a Drink.category field (beer, alc_free_beer, radler, alc_free_radler,
soft, water) and apply per-category gradient backgrounds to the booking
buttons so users can recognize drinks at a glance. Sort buttons by
category, shrink them to a 3:2 aspect ratio, and switch labels to more
verbose brand names (Sternburg Export, Ur-Krostitzer, etc.).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-14 22:56:27 +02:00
parent 2b46c7cd54
commit b10e434d0c
7 changed files with 132 additions and 20 deletions
+19 -2
View File
@@ -6,7 +6,7 @@ from django.contrib.admin.views.decorators import staff_member_required
from django.contrib.auth import authenticate, login, logout
from django.contrib.auth.decorators import login_required
from django.contrib.auth import get_user_model
from django.db.models import F, Sum
from django.db.models import Case, F, IntegerField, Sum, Value, When
from django.http import Http404, HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
@@ -173,7 +173,24 @@ def pin_view(request):
@require_http_methods(["GET"])
def me_view(request):
phase = _require_open(request)
drinks = Drink.objects.filter(year=current_year()).order_by("name") if phase == "booking" else Drink.objects.none()
drinks = (
Drink.objects.filter(year=current_year())
.annotate(
category_order=Case(
When(category="beer", then=Value(0)),
When(category="alc_free_beer", then=Value(1)),
When(category="radler", then=Value(2)),
When(category="alc_free_radler", then=Value(3)),
When(category="soft", then=Value(4)),
When(category="water", then=Value(5)),
default=Value(99),
output_field=IntegerField(),
)
)
.order_by("category_order", "name")
if phase == "booking"
else Drink.objects.none()
)
booked_drink = None
booked_id = request.GET.get("booked")
if booked_id: