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 { .drink-grid {
display: grid; display: grid;
grid-template-columns: repeat(2, 1fr); 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 import authenticate, login, logout
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.contrib.auth import get_user_model 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.http import Http404, HttpResponseRedirect
from django.shortcuts import render from django.shortcuts import render
from django.urls import reverse from django.urls import reverse
@@ -108,6 +108,16 @@ def _drink_grid_qs():
return ( return (
Drink.objects.filter(year=current_year()) Drink.objects.filter(year=current_year())
.annotate( .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( category_order=Case(
When(category="beer", then=Value(0)), When(category="beer", then=Value(0)),
When(category="alc_free_beer", then=Value(1)), When(category="alc_free_beer", then=Value(1)),
@@ -117,9 +127,9 @@ def _drink_grid_qs():
When(category="water", then=Value(5)), When(category="water", then=Value(5)),
default=Value(99), default=Value(99),
output_field=IntegerField(), output_field=IntegerField(),
),
) )
) .order_by("alcohol_order", "category_order", "name")
.order_by("category_order", "name")
) )
+5 -1
View File
@@ -73,8 +73,11 @@
}); });
}); });
</script> </script>
{% 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"> <div class="drink-grid">
{% for drink in drinks %} {% for drink in group.list %}
<button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}"> <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-plus">+1</span>
<span class="drink-name">{{ drink.name }}</span> <span class="drink-name">{{ drink.name }}</span>
@@ -82,6 +85,7 @@
</button> </button>
{% endfor %} {% endfor %}
</div> </div>
{% endfor %}
</form> </form>
</section> </section>
{% endif %} {% endif %}
+7 -1
View File
@@ -57,12 +57,17 @@
<input type="radio" name="booking_mode" value="for_free" /> <input type="radio" name="booking_mode" value="for_free" />
<span>Gratis (z.B. Artists am Spieltag)</span> <span>Gratis (z.B. Artists am Spieltag)</span>
</label> </label>
{% if not is_anonymous_target %}
<label class="for-free-toggle"> <label class="for-free-toggle">
<input type="radio" name="booking_mode" value="cash_paid" /> <input type="radio" name="booking_mode" value="cash_paid" />
<span>Direkt bar bezahlt</span> <span>Direkt bar bezahlt</span>
</label> </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"> <div class="drink-grid">
{% for drink in drinks %} {% for drink in group.list %}
<button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}"> <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-plus">+1</span>
<span class="drink-name">{{ drink.name }}</span> <span class="drink-name">{{ drink.name }}</span>
@@ -70,6 +75,7 @@
</button> </button>
{% endfor %} {% endfor %}
</div> </div>
{% endfor %}
</form> </form>
</section> </section>
{% endif %} {% endif %}