Add basic public dashboard
parent
2f9adbb11c
commit
4fb345b3bb
@ -0,0 +1,44 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block head %}
|
||||
<script>
|
||||
window.addEventListener('load', () => {
|
||||
const max = document.body.scrollHeight - window.innerHeight;
|
||||
let current = 0;
|
||||
let interval;
|
||||
let interacted = false;
|
||||
|
||||
window.addEventListener('click', () => interacted = true);
|
||||
window.addEventListener('touchstart', () => interacted = true);
|
||||
|
||||
setTimeout(() => {
|
||||
window.scrollTo({top: 0});
|
||||
}, 10);
|
||||
|
||||
if (max > 0) {
|
||||
setTimeout(() => {
|
||||
if (interacted) return;
|
||||
interval = setInterval(() => {
|
||||
if (interacted) return;
|
||||
current += 1;
|
||||
|
||||
window.scrollTo({top: current});
|
||||
|
||||
if (window.scrollY >= max) {
|
||||
if (interacted) return;
|
||||
clearInterval(interval);
|
||||
setTimeout(() => {
|
||||
window.location.reload();
|
||||
}, 5000)
|
||||
}
|
||||
}, 20);
|
||||
}, 5000)
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
if (interacted) return;
|
||||
window.location.reload();
|
||||
}, 120 * 1000)
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
@ -1,4 +1,50 @@
|
||||
{% extends "base.html" %}
|
||||
{% extends "autoscroll.html" %}
|
||||
|
||||
{% load qrcode %}
|
||||
|
||||
{% block everything %}
|
||||
<section class="hero">
|
||||
<div class="hero-body">
|
||||
<div class="container has-text-centered">
|
||||
<h2 class="title is-2">kontakt – das Kulturfestival</h2>
|
||||
<h1 class="title is-1">sucht dich!</h1>
|
||||
<h3 class="title">Schnapp dir deine Helfer*innenschicht auf https://helfen.kntkt.de</h3>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="hero is-link is-small">
|
||||
<div class="hero-body">
|
||||
<div class="container">
|
||||
<div class="level">
|
||||
{% for description, value in facts %}
|
||||
<div class="level-item has-text-centered">
|
||||
<div>
|
||||
<p class="heading">{{ description }}</p>
|
||||
<p class="title">{{ value }}</p>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<h3 class="title">Nächste freie Schichten</h3>
|
||||
<div class="columns">
|
||||
{% for shift in next_free_shifts %}
|
||||
<div class="column has-text-centered is-quarter">
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
<p class="is-size-4">{{ shift.start_at }}</p>
|
||||
{% url 'shift' shift.pk as shift_url %}
|
||||
{% qrcode "https://helfen.kntkt.de"|add:shift_url %}
|
||||
<p class="is-size-4 mt-4">{{ shift.room.name }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
{% endblock %}
|
||||
|
@ -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'))
|
@ -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)
|
||||
|
Loading…
Reference in New Issue