diff --git a/requirements.txt b/requirements.txt index bc37368..035527e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -24,14 +24,17 @@ phonenumbers==8.12.47 prompt-toolkit==3.0.29 psycopg2-binary==2.9.3 pyparsing==3.0.8 +pypng==0.20220715.0 python-dateutil==2.8.2 pytz==2022.1 +qrcode==7.4.2 redis==4.2.2 requests==2.27.1 sentry-sdk==1.5.10 six==1.16.0 soupsieve==2.4.1 sqlparse==0.4.2 +typing_extensions==4.5.0 urllib3==1.26.9 vine==5.0.0 wcwidth==0.2.5 diff --git a/shiftregister/signage/templates/autoscroll.html b/shiftregister/signage/templates/autoscroll.html new file mode 100644 index 0000000..d1951f0 --- /dev/null +++ b/shiftregister/signage/templates/autoscroll.html @@ -0,0 +1,44 @@ +{% extends "base.html" %} + +{% block head %} + +{% endblock %} diff --git a/shiftregister/signage/templates/public_dashboard.html b/shiftregister/signage/templates/public_dashboard.html index ae26e81..1199e8e 100644 --- a/shiftregister/signage/templates/public_dashboard.html +++ b/shiftregister/signage/templates/public_dashboard.html @@ -1,4 +1,50 @@ -{% extends "base.html" %} +{% extends "autoscroll.html" %} + +{% load qrcode %} {% block everything %} +
+
+
+

kontakt – das Kulturfestival

+

sucht dich!

+

Schnapp dir deine Helfer*innenschicht auf https://helfen.kntkt.de

+
+
+
+ +
+
+

Nächste freie Schichten

+
+{% for shift in next_free_shifts %} +
+
+
+

{{ shift.start_at }}

+ {% url 'shift' shift.pk as shift_url %} + {% qrcode "https://helfen.kntkt.de"|add:shift_url %} +

{{ shift.room.name }}

+
+
+
+{% endfor %} +
+
+
{% endblock %} diff --git a/shiftregister/signage/templates/terminal.html b/shiftregister/signage/templates/terminal.html index 4370a91..76f816a 100644 --- a/shiftregister/signage/templates/terminal.html +++ b/shiftregister/signage/templates/terminal.html @@ -1,47 +1,4 @@ -{% extends "base.html" %} - -{% block head %} - -{% endblock %} +{% extends "autoscroll.html" %} {% block body %}
diff --git a/shiftregister/signage/templatetags/__init__.py b/shiftregister/signage/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/shiftregister/signage/templatetags/qrcode.py b/shiftregister/signage/templatetags/qrcode.py new file mode 100644 index 0000000..b430ead --- /dev/null +++ b/shiftregister/signage/templatetags/qrcode.py @@ -0,0 +1,10 @@ +from django import template +from django.utils.safestring import mark_safe +from qrcode import make +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')) diff --git a/shiftregister/signage/views.py b/shiftregister/signage/views.py index fd290ee..c113794 100644 --- a/shiftregister/signage/views.py +++ b/shiftregister/signage/views.py @@ -1,4 +1,27 @@ +from django.db.models import F, Q, Sum from django.shortcuts import render +from django.utils import timezone +from .models import Helper, Shift, ShiftRegistration def public_dashboard(request): - return render(request, "public_dashboard.html", {}) + facts = [] + + num_helpers = Helper.objects.count() + 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")) + + 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")) + + 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] + + context = {"facts": facts, "next_free_shifts": next_free_shifts} + return render(request, "public_dashboard.html", context)