Group shifts by date
This commit is contained in:
parent
964de92b9d
commit
6d2d70e0d5
|
@ -19,11 +19,21 @@
|
|||
{% endif %}
|
||||
{% if free_shifts %}
|
||||
<h3 class="title">Freie Schichten</h3>
|
||||
<div class="breadcrumb has-bullet-separator">
|
||||
<ul>
|
||||
{% for day in days %}
|
||||
<li><a href="#{{ day|date:"Y-m-d" }}">{{ day|date:"l, d.m.Y" }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
{% for shifts in free_shifts %}
|
||||
<h5 class="subtitle" id="{{ shifts.0.start_at|date:"Y-m-d" }}">{{ shifts.0.start_at|date:"l, d.m.Y" }}</h5>
|
||||
<div class="columns is-multiline">
|
||||
{% for shift in free_shifts %}
|
||||
{% for shift in shifts %}
|
||||
{% include "partials/shift_listitem.html" %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="notification">
|
||||
Alle Schichten sind voll. Schau später noch mal vorbei.
|
||||
|
|
|
@ -20,9 +20,10 @@ def index(request):
|
|||
if request.session.get("last_seen_shift"):
|
||||
del request.session["last_seen_shift"]
|
||||
|
||||
# dont show shifts starting in <60 minutes?
|
||||
# currently only sorts by date
|
||||
context = {}
|
||||
context = {
|
||||
"days": Shift.objects.datetimes("start_at", "day"),
|
||||
}
|
||||
|
||||
if request.helper:
|
||||
context["my_future_shifts"] = (
|
||||
reg.shift
|
||||
|
@ -42,29 +43,24 @@ def index(request):
|
|||
help_wanted = Q(required_helpers__gt=F("reg_count")) | Q(required_helpers=0) & Q(
|
||||
room__required_helpers__gt=F("reg_count")
|
||||
)
|
||||
|
||||
# dont show shifts starting in <60 minutes?
|
||||
# currently only sorts by date
|
||||
free_shifts = (
|
||||
Shift.with_reg_count()
|
||||
.filter(
|
||||
help_wanted,
|
||||
start_at__date=day.date(),
|
||||
start_at__gt=timezone.now(),
|
||||
deleted=False,
|
||||
)
|
||||
.order_by("start_at")
|
||||
for day in Shift.objects.datetimes("start_at", "day")
|
||||
)
|
||||
|
||||
if request.helper:
|
||||
free_shifts = (
|
||||
Shift.with_reg_count()
|
||||
.filter(
|
||||
help_wanted,
|
||||
start_at__gt=timezone.now(),
|
||||
deleted=False,
|
||||
)
|
||||
.filter(~Q(shiftregistration__helper=request.helper))
|
||||
.order_by("start_at")
|
||||
)
|
||||
free_shifts = (day.filter(~Q(shiftregistration__helper=request.helper)) for day in free_shifts)
|
||||
|
||||
context["free_shifts"] = free_shifts
|
||||
context["free_shifts"] = list(map(lambda qs: list(qs), filter(lambda qs: qs.exists(), free_shifts)))
|
||||
return render(request, "shiftlist.html", context)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue