Compare commits

...

3 Commits

@ -140,6 +140,7 @@
</div>
</div>
</footer>
{% endblock %}
<script>
document.querySelectorAll('.delete').forEach(btn => btn.addEventListener('click', event => event.target.parentElement.remove()));
document.querySelectorAll('.navbar-burger').forEach(el => el.addEventListener('click', () => {
@ -167,6 +168,5 @@
}, false);
});
</script>
{% endblock %}
</body>
</html>

@ -3,6 +3,7 @@
{% block everything %}
<section class="section">
<div class="container">
{% include "notifications.html" %}
<h3 class="title" style="background:var(--background);margin:0 -1rem;padding:1rem;position:sticky;top:0;">Teamschichten für {{ today|date:"l, d. F Y" }}</h3>
<table class="table">
<thead style="background:inherit;position:sticky;top:4rem;">

@ -1,5 +1,6 @@
from datetime import timedelta
import datetime
from django.contrib import messages
from django.db import models
from django.db.models import Case, Count, ExpressionWrapper, F, Q, Sum, When
from django.shortcuts import render
@ -51,16 +52,31 @@ def public_dashboard(request):
def team_dashboard(request):
now = timezone.localtime()
changeover = now.replace(hour=6, minute=0, second=0, microsecond=0)
today = now.date()
if now.hour < changeover.hour:
day = None
exclude_past_shifts = True
if date := request.GET.get("date"):
try:
day = datetime.date.fromisoformat(date)
exclude_past_shifts = False
except ValueError:
messages.add_message(request, messages.ERROR, "Ungültiges Datum")
changeover = datetime.datetime.combine(
day or today, datetime.time(hour=6), timezone.get_current_timezone()
)
if day is None and now.hour < changeover.hour:
day_end = changeover
day_start = day_end - timedelta(days=1)
today = today - timedelta(days=1)
day_start = day_end - datetime.timedelta(days=1)
day = today - datetime.timedelta(days=1)
else:
day_start = changeover
day_end = day_start + timedelta(days=1)
day_end = day_start + datetime.timedelta(days=1)
if day is None:
day = today
team_shifts = (
Shift.with_reg_count()
@ -78,13 +94,15 @@ def team_dashboard(request):
deleted=False,
start_at__gte=day_start,
start_at__lt=day_end,
end_at__gt=now,
reg_count__lt=F("real_required_helpers"),
fallbackassignment_count__gt=0,
)
.order_by("start_at")
)
if exclude_past_shifts:
team_shifts = team_shifts.filter(end_at__gt=now)
return render(
request, "team_dashboard.html", {"today": today, "team_shifts": team_shifts}
request, "team_dashboard.html", {"today": day, "team_shifts": team_shifts}
)

Loading…
Cancel
Save