diff --git a/shiftregister/signage/templatetags/qrcode.py b/shiftregister/signage/templatetags/qrcode.py index b430ead..ed65a4f 100644 --- a/shiftregister/signage/templatetags/qrcode.py +++ b/shiftregister/signage/templatetags/qrcode.py @@ -5,6 +5,9 @@ from qrcode.image.svg import SvgPathFillImage register = template.Library() + @register.simple_tag def qrcode(data): - return mark_safe(make(data, image_factory=SvgPathFillImage).to_string().decode('utf-8')) + return mark_safe( + make(data, image_factory=SvgPathFillImage).to_string().decode("utf-8") + ) diff --git a/shiftregister/signage/views.py b/shiftregister/signage/views.py index c113794..b4c1578 100644 --- a/shiftregister/signage/views.py +++ b/shiftregister/signage/views.py @@ -3,6 +3,7 @@ from django.shortcuts import render from django.utils import timezone from .models import Helper, Shift, ShiftRegistration + def public_dashboard(request): facts = [] @@ -10,18 +11,35 @@ def public_dashboard(request): if num_helpers > 0: facts.append(("Registrierte Helfer*innen", num_helpers)) - help_wanted = Q(required_helpers__gt=F("reg_count")) | Q(required_helpers=0) & Q(room__required_helpers__gt=F("reg_count")) + help_wanted = Q(required_helpers__gt=F("reg_count")) | Q(required_helpers=0) & Q( + room__required_helpers__gt=F("reg_count") + ) - total_work_duration = ShiftRegistration.objects.filter(state=ShiftRegistration.RegState.CHECKED_IN).aggregate(sum=Sum("shift__duration"))["sum"] + total_work_duration = ShiftRegistration.objects.filter( + state=ShiftRegistration.RegState.CHECKED_IN + ).aggregate(sum=Sum("shift__duration"))["sum"] if total_work_duration: total_work_duration = round(total_work_duration.total_seconds() / 60.0) - facts.append(("Geleistete Personenstunden", f"{total_work_duration//60}h {total_work_duration%60}min")) + facts.append( + ( + "Geleistete Personenstunden", + f"{total_work_duration//60}h {total_work_duration%60}min", + ) + ) - num_free_shifts = Shift.with_reg_count().filter(help_wanted, deleted=False, start_at__gte=timezone.now()).count() + num_free_shifts = ( + Shift.with_reg_count() + .filter(help_wanted, deleted=False, start_at__gte=timezone.now()) + .count() + ) if num_free_shifts > 0: facts.append(("Zu übernehmende Schichten", num_free_shifts)) - next_free_shifts = Shift.with_reg_count().filter(help_wanted, start_at__gt=timezone.now(), deleted=False).order_by("start_at")[:4] + next_free_shifts = ( + Shift.with_reg_count() + .filter(help_wanted, start_at__gt=timezone.now(), deleted=False) + .order_by("start_at")[:4] + ) context = {"facts": facts, "next_free_shifts": next_free_shifts} return render(request, "public_dashboard.html", context)