2
0
Fork 0

Compare commits

..

10 Commits

15 changed files with 149 additions and 96 deletions

View File

@ -19,14 +19,13 @@
</section> </section>
{% endblock %} {% endblock %}
{% block footer %} {% block footer_content %}
<div class="content">
{% if DEBUG %} {% if DEBUG %}
<br>
(Debug-Modus) (Debug-Modus)
{% if helper %} {% if helper %}
<a href="{% url 'token_logout' %}">logout</a> <a href="{% url 'token_logout' %}">logout</a>
<a href="{{ helper.logintoken_set.first.get_absolute_url }}">login url</a> <a href="{{ helper.logintoken_set.first.get_absolute_url }}">login url</a>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div>
{% endblock %} {% endblock %}

View File

@ -14,6 +14,10 @@
src: url("{% static 'MavenPro-VariableFont:wght.ttf' %}"); src: url("{% static 'MavenPro-VariableFont:wght.ttf' %}");
} }
a:hover > .box {
background: #eee;
}
body { body {
font-family: "Maven Pro", sans-serif !important; font-family: "Maven Pro", sans-serif !important;
min-height: 100vh; min-height: 100vh;
@ -23,6 +27,10 @@
flex-grow: 1; flex-grow: 1;
} }
button, input, select, textarea {
font-family: inherit;
}
:root { :root {
--background: #fff; --background: #fff;
} }
@ -64,6 +72,10 @@
} }
@media (prefers-color-scheme: dark) { @media (prefers-color-scheme: dark) {
a:hover > .box {
background: #1a1a1a;
}
:root { :root {
--background: #17181c; --background: #17181c;
} }
@ -105,9 +117,11 @@
{% endblock %} {% endblock %}
<footer class="footer"> <footer class="footer">
<div class="container is-flex is-flex-wrap-wrap is-justify-content-space-between"> <div class="container is-flex is-flex-wrap-wrap is-justify-content-space-between">
{% block footer %} <div class="content">
<div class="content"><a href="https://git.as42.net/kontakt/shiftregister">shiftregister</a> by flo, Luca &amp; xAndy</div> <a href="https://git.as42.net/kontakt/shiftregister">shiftregister</a> by flo, Luca &amp; xAndy
{% block footer_content %}
{% endblock %} {% endblock %}
</div>
<div class="breadcrumb has-dot-separator is-flex-grow-1 is-right ml-5"> <div class="breadcrumb has-dot-separator is-flex-grow-1 is-right ml-5">
<ul> <ul>
{% for item in footer_nav_items %} {% for item in footer_nav_items %}

View File

@ -1,22 +1,22 @@
{% if page.has_other_pages %} {% if is_paginated %}
<nav class="pagination is-centered" role="navigation" aria-label="pagination"> <nav class="pagination is-centered" role="navigation" aria-label="pagination">
{% if page.has_previous %} {% if page_obj.has_previous %}
<a class="pagination-previous" href="?page={{ page.previous_page_number }}">&lt;</a> <a class="pagination-previous" href="?page={{ page_obj.previous_page_number }}">&lt;</a>
{% else %} {% else %}
<a class="pagination-previous is-disabled">&lt;</a> <a class="pagination-previous is-disabled">&lt;</a>
{% endif %} {% endif %}
{% if page.has_next %} {% if page_obj.has_next %}
<a class="pagination-next" href="?page={{ page.next_page_number }}">&gt;</a> <a class="pagination-next" href="?page={{ page_obj.next_page_number }}">&gt;</a>
{% else %} {% else %}
<a class="pagination-next is-disabled">&gt;</a> <a class="pagination-next is-disabled">&gt;</a>
{% endif %} {% endif %}
<ul class="pagination-list"> <ul class="pagination-list">
{% for p in page_range %} {% for p in page_range %}
<li> <li>
{% if p == page.paginator.ELLIPSIS %} {% if p == paginator.ELLIPSIS %}
<span class="pagination-ellipsis">{{ page.paginator.ELLIPSIS }}</span> <span class="pagination-ellipsis">{{ paginator.ELLIPSIS }}</span>
{% elif p == page.number %} {% elif p == page_obj.number %}
<a class="pagination-link is-current">{{ p }}</a> <span class="pagination-link is-current">{{ p }}</span>
{% else %} {% else %}
<a class="pagination-link" href="?page={{ p }}">{{ p }}</a> <a class="pagination-link" href="?page={{ p }}">{{ p }}</a>
{% endif %} {% endif %}

View File

@ -5,7 +5,7 @@
{% block content %} {% block content %}
<h3 class="title">{{ title }}</h3> <h3 class="title">{{ title }}</h3>
<table class="table"> <table class="table is-fullwidth">
<thead> <thead>
<tr> <tr>
<th>Name</th> <th>Name</th>
@ -16,7 +16,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for reg in object_list %} {% for reg in page_obj %}
<tr> <tr>
<td> <td>
<a href="{% url 'team:helper' reg.helper.pk %}"> <a href="{% url 'team:helper' reg.helper.pk %}">
@ -27,19 +27,26 @@
</a> </a>
</td> </td>
<td> <td>
<span class="{{ reg.shift.event.calendar.needs_fallback|yesno:"is-underlined," }}"> <a{% if reg.shift.event.calendar.needs_fallback %} class="is-underlined"{% endif %} href="{% url 'team:shift_room' reg.shift.room.pk %}">{{ reg.shift.room }}</a>
<a href="{% url 'team:shift_room' reg.shift.room.pk %}">{{ reg.shift.room }}</a>
</span>
</td> </td>
<td><a href="{% url 'team:shift' reg.shift.pk %}">{{ reg.shift.start_at }}</a></td> <td><a href="{% url 'team:shift' reg.shift.pk %}">{{ reg.shift.start_at }}</a></td>
<td><a href="{% url 'team:shift' reg.shift.pk %}">{{ reg.shift.duration|duration }}</a></td> <td><a href="{% url 'team:shift' reg.shift.pk %}">{{ reg.shift.duration|duration }}</a></td>
<td> <td>
<a class="button is-success is-small" href="{% url 'team:checkin' reg.pk %}">Als angekommen markieren</a> <div class="buttons">
<a class="button is-danger is-small" href="{% url 'team:mark_as_failed' reg.pk %}">Nicht angetreten</a> <form action="{% url 'team:checkin' reg.pk %}" method="post">
<a class="button is-link is-small" href="tel:{{ reg.helper.phone }}">📞</a> {% csrf_token %}
<button class="button is-success is-small mr-2" type="submit">Als angekommen markieren</button>
</form>
<form action="{% url 'team:mark_as_failed' reg.pk %}" method="post">
{% csrf_token %}
<button class="button is-danger is-small mr-2" type="submit">Nicht angetreten</button>
</form>
<a class="button is-link is-small" href="tel:{{ reg.helper.phone }}">📞</a>
</div>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
</table> </table>
{% include "pagination.html" %}
{% endblock %} {% endblock %}

View File

@ -0,0 +1,12 @@
{% extends "base.html" %}
{% block title %}{{ action|default:"Aktion bestätigen" }}{% endblock %}
{% block content %}
<h3 class="title">{{ action|default:"Aktion bestätigen" }}</h3>
<form method="POST">
{% csrf_token %}
<button class="button is-{{ button_style|default:"danger" }} is-small" type="submit">{{ button_text|default:"Bestätigen" }}</button>
</form>
<a class="button mt-3" href="{% url 'team:shift' reg.shift.pk %}">Zurück</a>
{% endblock %}

View File

@ -13,9 +13,7 @@
<h5 class="subtitle">Schichten</h5> <h5 class="subtitle">Schichten</h5>
<div class="columns is-multiline"> <div class="columns is-multiline">
{% for reg in helper.shiftregistration_set.all %} {% for reg in helper.shiftregistration_set.all %}
<a class="" href="{% url 'team:shift' reg.shift.id %}"> {% include 'partials/shift_list_item.html' with shift=reg.shift %}
{% include 'partials/shift_list_item.html' with shift=reg.shift %}
</a>
{% endfor %} {% endfor %}
</div> </div>
<h5 class="subtitle" id="history">Nachrichtenverlauf</h5> <h5 class="subtitle" id="history">Nachrichtenverlauf</h5>

View File

@ -7,7 +7,7 @@
{% block content %} {% block content %}
<h3 class="title">Eingehende Nachrichten</h3> <h3 class="title">Eingehende Nachrichten</h3>
{% for message in page %} {% for message in page_obj %}
<a href="{% if message.from_helper %}{% url 'team:helper' message.from_helper.pk %}#history{% else %}{% url 'team:incoming_message' message.pk %}{% endif %}"> <a href="{% if message.from_helper %}{% url 'team:helper' message.from_helper.pk %}#history{% else %}{% url 'team:incoming_message' message.pk %}{% endif %}">
<div class="message{% if not message.read %} is-info{% endif %} mb-5"> <div class="message{% if not message.read %} is-info{% endif %} mb-5">
<div class="message-header"> <div class="message-header">

View File

@ -1,12 +0,0 @@
{% extends "base.html" %}
{% block title %}Helfer*in wirklich sperren?{% endblock %}
{% block content %}
<h3 class="title">Helfer*in wirklich sperren?</h3>
<form method="POST">
{% csrf_token %}
<button class="button is-danger is-small" type="submit">Schicht als "nicht angetreten" markieren und Helfer*in sperren</button>
</form>
<a class="button mt-3" href="{% url 'team:shift' reg.shift.pk %}">Zurück</a>
{% endblock %}

View File

@ -1,18 +1,17 @@
<div class="box"> <a href="{% url 'team:shift' shift.pk %}">
<div class="content"> <div class="box">
<div class="content">
{% if shift.deleted %} {% if shift.deleted %}
<em>gelöscht</em><br> <em>gelöscht</em><br>
{% endif %} {% endif %}
<strong>Ort:</strong> <span class="{{ shift.event.calendar.needs_fallback|yesno:"is-underlined," }}">{{ shift.room.name }}</span><br> <strong>Ort:</strong> <span class="{{ shift.event.calendar.needs_fallback|yesno:"is-underlined," }}">{{ shift.room.name }}</span><br>
<strong>Beginn:</strong> {{ shift.start_at }}<br> <strong>Beginn:</strong> {{ shift.start_at }}<br>
<strong>Dauer:</strong> {{ shift.duration }}<br> <strong>Dauer:</strong> {{ shift.duration }}<br>
<strong>Belegung:</strong> {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }} <strong>Belegung:</strong> {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
{% if shift.checkin_count is not None %} {% if shift.checkin_count is not None %}
<br> <br>
<strong>Checkin-Status:</strong> {% if shift.checkin_count >= shift.required_helpers|default:shift.room.required_helpers %}<span class="tag is-rounded is-success">vollständig</span>{% elif shift.checkin_count > 0 %}<span class="tag is-rounded is-warning">teilweise</span>{% else %}<span class="tag is-rounded is-danger">kein Checkin</span>{% endif %} <strong>Checkin-Status:</strong> {% if shift.checkin_count >= shift.required_helpers|default:shift.room.required_helpers %}<span class="tag is-rounded is-success">vollständig</span>{% elif shift.checkin_count > 0 %}<span class="tag is-rounded is-warning">teilweise</span>{% else %}<span class="tag is-rounded is-danger">kein Checkin</span>{% endif %}
{% endif %} {% endif %}
</div>
</div> </div>
<div class="buttons is-right mt-3"> </a>
<a class="button is-info is-small mr-0" href="{% url 'team:shift' shift.id %}">Details</a>
</div>
</div>

View File

@ -1,18 +1,20 @@
{% extends "base.html" %} {% extends "base.html" %}
{% block title %}{{ room.name }}{% endblock %}
{% block everything %} {% block everything %}
<section class="section"> <section class="section">
<div class="container"> <div class="container">
<h3 class="title" style="background:var(--background);margin:0 -1rem;padding:1rem;position:sticky;top:0;">Helfer:innen für {{ room.name }}</h3> <h3 class="title" style="background:var(--background);margin:0 -1rem;padding:1rem;position:sticky;top:0;">Helfer*innen für {{ room.name }}</h3>
<table class="table"> <table class="table">
<thead style="background:inherit;position:sticky;top:4rem;"> <thead style="background:inherit;position:sticky;top:4rem;">
<tr> <tr>
<th>Startzeit</th> <th>Startzeit</th>
<th>Helfer:innen</th> <th>Helfer*innen</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
{% for shift in room.valid_shifts.all|dictsort:"start_at" %} {% for shift in shifts %}
<tr> <tr>
<td>{{ shift.start_at }}</td> <td>{{ shift.start_at }}</td>
<td>{% for reg in shift.valid_registrations.all %}{{ reg.helper.name }}{% if not forloop.last %}, {% endif %}{% endfor %}</td> <td>{% for reg in shift.valid_registrations.all %}{{ reg.helper.name }}{% if not forloop.last %}, {% endif %}{% endfor %}</td>

View File

@ -32,9 +32,18 @@
</div> </div>
<div class="buttons"> <div class="buttons">
{% if reg.is_pending %} {% if reg.is_pending %}
<a class="button is-success is-small" href="{% url 'team:checkin' reg.pk %}">Als angekommen markieren</a> <form action="{% url 'team:checkin' reg.pk %}" method="post">
<a class="button is-warning is-small" href="{% url 'team:unregister' reg.pk %}">Helfer*in abmelden</a> {% csrf_token %}
<a class="button is-danger is-small" href="{% url 'team:mark_as_failed' reg.pk %}">Nicht angetreten</a> <button class="button is-success is-small mr-2" type="submit">Als angekommen markieren</button>
</form>
<form action="{% url 'team:unregister' reg.pk %}" method="post">
{% csrf_token %}
<button class="button is-warning is-small mr-2" type="submit">Helfer*in abmelden</button>
</form>
<form action="{% url 'team:mark_as_failed' reg.pk %}" method="post">
{% csrf_token %}
<button class="button is-danger is-small" type="submit">Nicht angetreten</button>
</form>
{% elif reg.is_checked_in %} {% elif reg.is_checked_in %}
<button class="button is-success is-small" style="pointer-events:none;"></button> <button class="button is-success is-small" style="pointer-events:none;"></button>
{% endif %} {% endif %}

View File

@ -6,9 +6,7 @@
<h3 class="title">{{ title }}</h3> <h3 class="title">{{ title }}</h3>
<div class="columns is-multiline"> <div class="columns is-multiline">
{% for shift in object_list %} {% for shift in object_list %}
<a class="" href="{% url 'team:shift' shift.id %}"> {% include "partials/shift_list_item.html" %}
{% include "partials/shift_list_item.html" %}
</a>
{% endfor %} {% endfor %}
</div> </div>
{% endblock %} {% endblock %}

View File

@ -25,9 +25,7 @@
{% for shift in next_shifts_per_room %} {% for shift in next_shifts_per_room %}
<div class="column is-one-quarter"> <div class="column is-one-quarter">
<h5 class="subtitle"><a href="{% url 'team:shift_room' shift.room.name %}">{{ shift.room.name }}</a></h5> <h5 class="subtitle"><a href="{% url 'team:shift_room' shift.room.name %}">{{ shift.room.name }}</a></h5>
<a href="{% url 'team:shift' shift.id %}"> {% include "partials/shift_box.html" %}
{% include "partials/shift_box.html" %}
</a>
</div> </div>
{% endfor %} {% endfor %}
</div> </div>

View File

@ -16,7 +16,7 @@ urlpatterns = [
path("checkin/<int:pk>", views.checkin, name="checkin"), path("checkin/<int:pk>", views.checkin, name="checkin"),
path("mark_as_failed/<int:pk>", views.mark_as_failed, name="mark_as_failed"), path("mark_as_failed/<int:pk>", views.mark_as_failed, name="mark_as_failed"),
path("remove_helper/<int:pk>", views.delete_shiftregistration, name="unregister"), path("remove_helper/<int:pk>", views.delete_shiftregistration, name="unregister"),
path("incoming/", views.incoming_messages, name="incoming_messages"), path("incoming/", views.IncomingMessagesList.as_view(), name="incoming_messages"),
path("incoming/<slug:pk>", views.incoming_message, name="incoming_message"), path("incoming/<slug:pk>", views.incoming_message, name="incoming_message"),
path("incoming/mark_as_read/<slug:pk>", views.mark_as_read, name="mark_as_read"), path("incoming/mark_as_read/<slug:pk>", views.mark_as_read, name="mark_as_read"),
path("list/<slug:token>", views.room_view_token, name="room_view_token"), path("list/<slug:token>", views.room_view_token, name="room_view_token"),

View File

@ -284,31 +284,42 @@ class RoomShiftList(ShiftList):
class CheckinList(LoginRequiredMixin, ListView): class CheckinList(LoginRequiredMixin, ListView):
paginate_by = 30
template_name = "checkin_list.html" template_name = "checkin_list.html"
model = Shift title = "Ankommende Helfer*innen"
title = "Ankommende Helfer:innen"
def get_queryset(self): def get_queryset(self):
return ShiftRegistration.objects.filter( return (
shift__deleted=False, ShiftRegistration.objects.select_related("helper", "shift")
state=ShiftRegistration.RegState.REGISTERED, .prefetch_related("shift__event__calendar")
).order_by("shift__start_at")[:30] .filter(shift__deleted=False, state=ShiftRegistration.RegState.REGISTERED)
.order_by("shift__start_at", "shift__room__name")
)
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
context["page_range"] = context["paginator"].get_elided_page_range(
context["page_obj"].number
)
context["title"] = self.title context["title"] = self.title
return context return context
def get_ordering(self):
return ("start_at", "room__name")
@login_required @login_required
def checkin(request, pk): def checkin(request, pk):
reg = get_object_or_404(ShiftRegistration, pk=pk) reg = get_object_or_404(ShiftRegistration, pk=pk)
reg.state = reg.RegState.CHECKED_IN
reg.save() if request.method == "POST":
return redirect("team:shift", pk=reg.shift.pk) reg.state = reg.RegState.CHECKED_IN
reg.save()
return redirect("team:shift", pk=reg.shift.pk)
return render(
request,
"csrf_protect.html",
{"action": "Als angekommen markieren", "button_text": "Angekommen", "reg": reg},
)
@login_required @login_required
@ -324,33 +335,50 @@ def mark_as_failed(request, pk):
return redirect("team:shift", pk=reg.shift.pk) return redirect("team:shift", pk=reg.shift.pk)
return render(request, "molly_guard.html", {"reg": reg}) return render(
request,
"csrf_protect.html",
{
"action": 'Schicht als "nicht angetreten" markieren',
"button_text": "Nicht angetreten",
"reg": reg,
},
)
@login_required @login_required
def delete_shiftregistration(request, pk): def delete_shiftregistration(request, pk):
reg = get_object_or_404(ShiftRegistration, pk=pk) reg = get_object_or_404(ShiftRegistration, pk=pk)
spk = reg.shift.pk
reg.delete()
return redirect("team:shift", pk=spk)
if request.method == "POST":
reg.delete()
@login_required return redirect("team:shift", pk=reg.shift.pk)
def incoming_messages(request):
p = Paginator(IncomingMessage.objects.order_by("read", "-created_at"), 10)
page = p.get_page(request.GET.get("page"))
return render( return render(
request, request,
"incoming_messages.html", "csrf_protect.html",
{ {"action": "Helfer*in abmelden", "button_text": "Abmelden", "reg": reg},
"num_unread": IncomingMessage.objects.filter(read=False).count(),
"page": page,
"page_range": p.get_elided_page_range(page.number),
},
) )
class IncomingMessagesList(LoginRequiredMixin, ListView):
model = IncomingMessage
paginate_by = 10
template_name = "incoming_messages.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["num_unread"] = IncomingMessage.objects.filter(read=False).count()
context["page_range"] = context["paginator"].get_elided_page_range(
context["page_obj"].number
)
return context
def get_ordering(self):
return ("read", "-created_at")
@login_required @login_required
def incoming_message(request, pk): def incoming_message(request, pk):
message = get_object_or_404(IncomingMessage, pk=pk) message = get_object_or_404(IncomingMessage, pk=pk)
@ -373,10 +401,11 @@ def mark_as_read(request, pk):
def room_view_token(request, token): def room_view_token(request, token):
token = get_object_or_404(RoomViewToken, pk=token)
room = token.room
return render( return render(
request, request,
"room_registrations.html", "room_registrations.html",
{ {"room": room, "shifts": room.valid_shifts().order_by("start_at")},
"room": get_object_or_404(RoomViewToken, pk=token).room,
},
) )