Add basic team dashboard
This commit is contained in:
parent
a43fc266af
commit
e007e67e83
|
@ -0,0 +1,27 @@
|
||||||
|
{% extends "autoscroll.html" %}
|
||||||
|
|
||||||
|
{% block everything %}
|
||||||
|
<section class="section">
|
||||||
|
<div class="container">
|
||||||
|
<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;">
|
||||||
|
<tr>
|
||||||
|
<th>Schicht</th>
|
||||||
|
<th>Startzeit</th>
|
||||||
|
<th>Teammitglied(er)</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
{% for shift in team_shifts %}
|
||||||
|
<tr>
|
||||||
|
<td>{{ shift.room.name }}</td>
|
||||||
|
<td>{{ shift.start_at }}</td>
|
||||||
|
<td>{% for fa in shift.fallbackassignment_set.all %}{{ fa.team_member.name }}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
|
@ -5,4 +5,5 @@ from . import views
|
||||||
app_name = "signage"
|
app_name = "signage"
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path("public/", views.public_dashboard, name="public_dashboard"),
|
path("public/", views.public_dashboard, name="public_dashboard"),
|
||||||
|
path("team/", views.team_dashboard, name="team_dashboard"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
from django.db.models import F, Q, Sum
|
from datetime import timedelta
|
||||||
|
from django.db.models import Case, Count, F, Q, Sum, When
|
||||||
from django.shortcuts import render
|
from django.shortcuts import render
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from .models import Helper, Shift, ShiftRegistration
|
from .models import Helper, Shift, ShiftRegistration
|
||||||
|
@ -43,3 +44,31 @@ def public_dashboard(request):
|
||||||
|
|
||||||
context = {"facts": facts, "next_free_shifts": next_free_shifts}
|
context = {"facts": facts, "next_free_shifts": next_free_shifts}
|
||||||
return render(request, "public_dashboard.html", context)
|
return render(request, "public_dashboard.html", context)
|
||||||
|
|
||||||
|
|
||||||
|
def team_dashboard(request):
|
||||||
|
today = timezone.now().date()
|
||||||
|
|
||||||
|
team_shifts = (
|
||||||
|
Shift.with_reg_count()
|
||||||
|
.annotate(
|
||||||
|
real_required_helpers=Case(
|
||||||
|
When(required_helpers=0, then=F("room__required_helpers")),
|
||||||
|
default=F("required_helpers"),
|
||||||
|
),
|
||||||
|
fallbackassignment_count=Count("fallbackassignment"),
|
||||||
|
)
|
||||||
|
.filter(
|
||||||
|
deleted=False,
|
||||||
|
start_at__gt=today + timedelta(hours=6),
|
||||||
|
start_at__lte=today + timedelta(hours=30),
|
||||||
|
start_at__gte=timezone.now(),
|
||||||
|
reg_count__lt=F("real_required_helpers"),
|
||||||
|
fallbackassignment_count__gt=0,
|
||||||
|
)
|
||||||
|
.order_by("start_at")
|
||||||
|
)
|
||||||
|
|
||||||
|
return render(
|
||||||
|
request, "team_dashboard.html", {"today": today, "team_shifts": team_shifts}
|
||||||
|
)
|
||||||
|
|
Loading…
Reference in New Issue