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("category_order", "name") .order_by("alcohol_order", "category_order", "name")
) )
+13 -9
View File
@@ -73,15 +73,19 @@
}); });
}); });
</script> </script>
<div class="drink-grid"> {% regroup drinks by alcohol_label as drink_groups %}
{% for drink in drinks %} {% for group in drink_groups %}
<button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}"> <h4 class="drink-group-heading">{{ group.grouper }}</h4>
<span class="drink-plus">+1</span> <div class="drink-grid">
<span class="drink-name">{{ drink.name }}</span> {% for drink in group.list %}
<span class="drink-price">{{ drink.sale_price_per_bottle|floatformat:2 }} €</span> <button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}">
</button> <span class="drink-plus">+1</span>
{% endfor %} <span class="drink-name">{{ drink.name }}</span>
</div> <span class="drink-price">{{ drink.sale_price_per_bottle|floatformat:2 }} €</span>
</button>
{% endfor %}
</div>
{% endfor %}
</form> </form>
</section> </section>
{% endif %} {% endif %}
+19 -13
View File
@@ -57,19 +57,25 @@
<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>
<label class="for-free-toggle"> {% if not is_anonymous_target %}
<input type="radio" name="booking_mode" value="cash_paid" /> <label class="for-free-toggle">
<span>Direkt bar bezahlt</span> <input type="radio" name="booking_mode" value="cash_paid" />
</label> <span>Direkt bar bezahlt</span>
<div class="drink-grid"> </label>
{% for drink in drinks %} {% endif %}
<button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}"> {% regroup drinks by alcohol_label as drink_groups %}
<span class="drink-plus">+1</span> {% for group in drink_groups %}
<span class="drink-name">{{ drink.name }}</span> <h4 class="drink-group-heading">{{ group.grouper }}</h4>
<span class="drink-price">{{ drink.sale_price_per_bottle|floatformat:2 }} €</span> <div class="drink-grid">
</button> {% for drink in group.list %}
{% endfor %} <button type="submit" name="drink_id" value="{{ drink.id }}" class="drink-btn drink-btn-{{ drink.category }}">
</div> <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> </form>
</section> </section>
{% endif %} {% endif %}