Do not show running shifts if there are none
This commit is contained in:
parent
6ca0958909
commit
c08eaf6a2e
|
@ -10,8 +10,8 @@
|
||||||
{% include "partials/shift_list_item.html" %}
|
{% include "partials/shift_list_item.html" %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
|
||||||
<hr>
|
<hr>
|
||||||
|
{% endif %}
|
||||||
<h3 class="title is-spaced">Nächste Schichten pro Raum</h3>
|
<h3 class="title is-spaced">Nächste Schichten pro Raum</h3>
|
||||||
<div class="columns">
|
<div class="columns">
|
||||||
{% for shift in next_shifts %}
|
{% for shift in next_shifts %}
|
||||||
|
|
|
@ -17,7 +17,7 @@ def index(request):
|
||||||
@login_required
|
@login_required
|
||||||
def shift_overview(request):
|
def shift_overview(request):
|
||||||
context = {}
|
context = {}
|
||||||
context["running_shifts"] = (
|
context["running_shifts"] = [
|
||||||
shift
|
shift
|
||||||
for shift in Shift.objects.annotate(
|
for shift in Shift.objects.annotate(
|
||||||
end_at=ExpressionWrapper(
|
end_at=ExpressionWrapper(
|
||||||
|
@ -27,15 +27,15 @@ def shift_overview(request):
|
||||||
)
|
)
|
||||||
.filter(start_at__lte=timezone.now(), end_at__gte=timezone.now())
|
.filter(start_at__lte=timezone.now(), end_at__gte=timezone.now())
|
||||||
.order_by("start_at")
|
.order_by("start_at")
|
||||||
)
|
]
|
||||||
|
|
||||||
# probably can do some distinct/group by stuff but not sure how tih django queries
|
# probably can do some distinct/group by stuff but not sure how tih django queries
|
||||||
context["next_shifts"] = (
|
context["next_shifts"] = [
|
||||||
Shift.objects.filter(room=room, start_at__gt=timezone.now())
|
Shift.objects.filter(room=room, start_at__gt=timezone.now())
|
||||||
.order_by("start_at")
|
.order_by("start_at")
|
||||||
.first()
|
.first()
|
||||||
for room in Room.objects.all()
|
for room in Room.objects.all()
|
||||||
)
|
]
|
||||||
|
|
||||||
return render(request, "shift_overview.html", context)
|
return render(request, "shift_overview.html", context)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue