Compare commits

..

3 Commits

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

@ -3,6 +3,7 @@
{% block everything %} {% block everything %}
<section class="section"> <section class="section">
<div class="container"> <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> <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"> <table class="table">
<thead style="background:inherit;position:sticky;top:4rem;"> <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 import models
from django.db.models import Case, Count, ExpressionWrapper, F, Q, Sum, When from django.db.models import Case, Count, ExpressionWrapper, F, Q, Sum, When
from django.shortcuts import render from django.shortcuts import render
@ -51,16 +52,31 @@ def public_dashboard(request):
def team_dashboard(request): def team_dashboard(request):
now = timezone.localtime() now = timezone.localtime()
changeover = now.replace(hour=6, minute=0, second=0, microsecond=0)
today = now.date() 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_end = changeover
day_start = day_end - timedelta(days=1) day_start = day_end - datetime.timedelta(days=1)
today = today - timedelta(days=1) day = today - datetime.timedelta(days=1)
else: else:
day_start = changeover 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 = ( team_shifts = (
Shift.with_reg_count() Shift.with_reg_count()
@ -78,13 +94,15 @@ def team_dashboard(request):
deleted=False, deleted=False,
start_at__gte=day_start, start_at__gte=day_start,
start_at__lt=day_end, start_at__lt=day_end,
end_at__gt=now,
reg_count__lt=F("real_required_helpers"), reg_count__lt=F("real_required_helpers"),
fallbackassignment_count__gt=0, fallbackassignment_count__gt=0,
) )
.order_by("start_at") .order_by("start_at")
) )
if exclude_past_shifts:
team_shifts = team_shifts.filter(end_at__gt=now)
return render( 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