split drinks by with/without alcohol + disable direct-cash button for anonym

This commit is contained in:
2026-05-31 17:53:45 +02:00
parent 23b24ed0b9
commit 3ef2037917
4 changed files with 58 additions and 25 deletions
+13
View File
@@ -356,6 +356,19 @@ section {
}
.drink-group-heading {
font-size: 0.95rem;
font-weight: bold;
color: #EE9933;
margin: 14px 0 8px 4px;
text-transform: uppercase;
letter-spacing: 0.05em;
}
.drink-group-heading:first-child {
margin-top: 0;
}
.drink-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
+13 -3
View File
@@ -7,7 +7,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 Case, Count, F, IntegerField, Sum, Value, When
from django.db.models import Case, CharField, Count, F, IntegerField, Sum, Value, When
from django.http import Http404, HttpResponseRedirect
from django.shortcuts import render
from django.urls import reverse
@@ -108,6 +108,16 @@ def _drink_grid_qs():
return (
Drink.objects.filter(year=current_year())
.annotate(
alcohol_order=Case(
When(category__in=["beer", "radler"], then=Value(0)),
default=Value(1),
output_field=IntegerField(),
),
alcohol_label=Case(
When(category__in=["beer", "radler"], then=Value("mit Alkohol")),
default=Value("ohne Alkohol"),
output_field=CharField(),
),
category_order=Case(
When(category="beer", then=Value(0)),
When(category="alc_free_beer", then=Value(1)),
@@ -117,9 +127,9 @@ def _drink_grid_qs():
When(category="water", then=Value(5)),
default=Value(99),
output_field=IntegerField(),
)
),
)
.order_by("category_order", "name")
.order_by("alcohol_order", "category_order", "name")
)
+13 -9
View File
@@ -73,15 +73,19 @@
});
});
</script>
<div class="drink-grid">
{% for drink in drinks %}
<button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}">
<span class="drink-plus">+1</span>
<span class="drink-name">{{ drink.name }}</span>
<span class="drink-price">{{ drink.sale_price_per_bottle|floatformat:2 }} €</span>
</button>
{% endfor %}
</div>
{% regroup drinks by alcohol_label as drink_groups %}
{% for group in drink_groups %}
<h4 class="drink-group-heading">{{ group.grouper }}</h4>
<div class="drink-grid">
{% for drink in group.list %}
<button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}">
<span class="drink-plus">+1</span>
<span class="drink-name">{{ drink.name }}</span>
<span class="drink-price">{{ drink.sale_price_per_bottle|floatformat:2 }} €</span>
</button>
{% endfor %}
</div>
{% endfor %}
</form>
</section>
{% endif %}
+19 -13
View File
@@ -57,19 +57,25 @@
<input type="radio" name="booking_mode" value="for_free" />
<span>Gratis (z.B. Artists am Spieltag)</span>
</label>
<label class="for-free-toggle">
<input type="radio" name="booking_mode" value="cash_paid" />
<span>Direkt bar bezahlt</span>
</label>
<div class="drink-grid">
{% for drink in drinks %}
<button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}">
<span class="drink-plus">+1</span>
<span class="drink-name">{{ drink.name }}</span>
<span class="drink-price">{{ drink.sale_price_per_bottle|floatformat:2 }} €</span>
</button>
{% endfor %}
</div>
{% if not is_anonymous_target %}
<label class="for-free-toggle">
<input type="radio" name="booking_mode" value="cash_paid" />
<span>Direkt bar bezahlt</span>
</label>
{% endif %}
{% regroup drinks by alcohol_label as drink_groups %}
{% for group in drink_groups %}
<h4 class="drink-group-heading">{{ group.grouper }}</h4>
<div class="drink-grid">
{% for drink in group.list %}
<button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}">
<span class="drink-plus">+1</span>
<span class="drink-name">{{ drink.name }}</span>
<span class="drink-price">{{ drink.sale_price_per_bottle|floatformat:2 }} €</span>
</button>
{% endfor %}
</div>
{% endfor %}
</form>
</section>
{% endif %}