2
0
Fork 0

Reformat code using black

This commit is contained in:
Luca 2023-05-16 15:11:51 +02:00
parent 0cf0ada124
commit 0558cad9fe
2 changed files with 27 additions and 6 deletions

View File

@ -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")
)

View File

@ -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)