2
0
Fork 0

Compare commits

..

No commits in common. "0679a1cc01e36ddc577cdddbf12438d07278e47c" and "33a07a0415cf0547f710948b4ebc45ff5517bf54" have entirely different histories.

3 changed files with 9 additions and 28 deletions

View File

@ -140,7 +140,6 @@
</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', () => {
@ -168,5 +167,6 @@
}, false);
});
</script>
{% endblock %}
</body>
</html>

View File

@ -3,7 +3,6 @@
{% 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;">

View File

@ -1,6 +1,5 @@
import datetime
from datetime import timedelta
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
@ -52,31 +51,16 @@ 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()
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:
if now.hour < changeover.hour:
day_end = changeover
day_start = day_end - datetime.timedelta(days=1)
day = today - datetime.timedelta(days=1)
day_start = day_end - timedelta(days=1)
today = today - timedelta(days=1)
else:
day_start = changeover
day_end = day_start + datetime.timedelta(days=1)
if day is None:
day = today
day_end = day_start + timedelta(days=1)
team_shifts = (
Shift.with_reg_count()
@ -94,15 +78,13 @@ 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": day, "team_shifts": team_shifts}
request, "team_dashboard.html", {"today": today, "team_shifts": team_shifts}
)