2
0
Fork 0

Compare commits

...

10 Commits

15 changed files with 149 additions and 96 deletions

View File

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

View File

@ -14,6 +14,10 @@
src: url("{% static 'MavenPro-VariableFont:wght.ttf' %}");
}
a:hover > .box {
background: #eee;
}
body {
font-family: "Maven Pro", sans-serif !important;
min-height: 100vh;
@ -23,6 +27,10 @@
flex-grow: 1;
}
button, input, select, textarea {
font-family: inherit;
}
:root {
--background: #fff;
}
@ -64,6 +72,10 @@
}
@media (prefers-color-scheme: dark) {
a:hover > .box {
background: #1a1a1a;
}
:root {
--background: #17181c;
}
@ -105,9 +117,11 @@
{% endblock %}
<footer class="footer">
<div class="container is-flex is-flex-wrap-wrap is-justify-content-space-between">
{% block footer %}
<div class="content"><a href="https://git.as42.net/kontakt/shiftregister">shiftregister</a> by flo, Luca &amp; xAndy</div>
<div class="content">
<a href="https://git.as42.net/kontakt/shiftregister">shiftregister</a> by flo, Luca &amp; xAndy
{% block footer_content %}
{% endblock %}
</div>
<div class="breadcrumb has-dot-separator is-flex-grow-1 is-right ml-5">
<ul>
{% 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">
{% if page.has_previous %}
<a class="pagination-previous" href="?page={{ page.previous_page_number }}">&lt;</a>
{% if page_obj.has_previous %}
<a class="pagination-previous" href="?page={{ page_obj.previous_page_number }}">&lt;</a>
{% else %}
<a class="pagination-previous is-disabled">&lt;</a>
{% endif %}
{% if page.has_next %}
<a class="pagination-next" href="?page={{ page.next_page_number }}">&gt;</a>
{% if page_obj.has_next %}
<a class="pagination-next" href="?page={{ page_obj.next_page_number }}">&gt;</a>
{% else %}
<a class="pagination-next is-disabled">&gt;</a>
{% endif %}
<ul class="pagination-list">
{% for p in page_range %}
<li>
{% if p == page.paginator.ELLIPSIS %}
<span class="pagination-ellipsis">{{ page.paginator.ELLIPSIS }}</span>
{% elif p == page.number %}
<a class="pagination-link is-current">{{ p }}</a>
{% if p == paginator.ELLIPSIS %}
<span class="pagination-ellipsis">{{ paginator.ELLIPSIS }}</span>
{% elif p == page_obj.number %}
<span class="pagination-link is-current">{{ p }}</span>
{% else %}
<a class="pagination-link" href="?page={{ p }}">{{ p }}</a>
{% endif %}

View File

@ -5,7 +5,7 @@
{% block content %}
<h3 class="title">{{ title }}</h3>
<table class="table">
<table class="table is-fullwidth">
<thead>
<tr>
<th>Name</th>
@ -16,7 +16,7 @@
</tr>
</thead>
<tbody>
{% for reg in object_list %}
{% for reg in page_obj %}
<tr>
<td>
<a href="{% url 'team:helper' reg.helper.pk %}">
@ -27,19 +27,26 @@
</a>
</td>
<td>
<span class="{{ reg.shift.event.calendar.needs_fallback|yesno:"is-underlined," }}">
<a href="{% url 'team:shift_room' reg.shift.room.pk %}">{{ reg.shift.room }}</a>
</span>
<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>
</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 class="button is-success is-small" href="{% url 'team:checkin' reg.pk %}">Als angekommen markieren</a>
<a class="button is-danger is-small" href="{% url 'team:mark_as_failed' reg.pk %}">Nicht angetreten</a>
<div class="buttons">
<form action="{% url 'team:checkin' reg.pk %}" method="post">
{% 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>
</tr>
{% endfor %}
</tbody>
</table>
{% include "pagination.html" %}
{% 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>
<div class="columns is-multiline">
{% 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 %}
</a>
{% endfor %}
</div>
<h5 class="subtitle" id="history">Nachrichtenverlauf</h5>

View File

@ -7,7 +7,7 @@
{% block content %}
<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 %}">
<div class="message{% if not message.read %} is-info{% endif %} mb-5">
<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,3 +1,4 @@
<a href="{% url 'team:shift' shift.pk %}">
<div class="box">
<div class="content">
{% if shift.deleted %}
@ -12,7 +13,5 @@
<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 %}
</div>
<div class="buttons is-right mt-3">
<a class="button is-info is-small mr-0" href="{% url 'team:shift' shift.id %}">Details</a>
</div>
</div>
</a>

View File

@ -1,18 +1,20 @@
{% extends "base.html" %}
{% block title %}{{ room.name }}{% endblock %}
{% block everything %}
<section class="section">
<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">
<thead style="background:inherit;position:sticky;top:4rem;">
<tr>
<th>Startzeit</th>
<th>Helfer:innen</th>
<th>Helfer*innen</th>
</tr>
</thead>
<tbody>
{% for shift in room.valid_shifts.all|dictsort:"start_at" %}
{% for shift in shifts %}
<tr>
<td>{{ shift.start_at }}</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 class="buttons">
{% if reg.is_pending %}
<a class="button is-success is-small" href="{% url 'team:checkin' reg.pk %}">Als angekommen markieren</a>
<a class="button is-warning is-small" href="{% url 'team:unregister' reg.pk %}">Helfer*in abmelden</a>
<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">
{% csrf_token %}
<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 %}
<button class="button is-success is-small" style="pointer-events:none;"></button>
{% endif %}

View File

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

View File

@ -25,9 +25,7 @@
{% for shift in next_shifts_per_room %}
<div class="column is-one-quarter">
<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" %}
</a>
</div>
{% endfor %}
</div>

View File

@ -16,7 +16,7 @@ urlpatterns = [
path("checkin/<int:pk>", views.checkin, name="checkin"),
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("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/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"),

View File

@ -284,32 +284,43 @@ class RoomShiftList(ShiftList):
class CheckinList(LoginRequiredMixin, ListView):
paginate_by = 30
template_name = "checkin_list.html"
model = Shift
title = "Ankommende Helfer:innen"
title = "Ankommende Helfer*innen"
def get_queryset(self):
return ShiftRegistration.objects.filter(
shift__deleted=False,
state=ShiftRegistration.RegState.REGISTERED,
).order_by("shift__start_at")[:30]
return (
ShiftRegistration.objects.select_related("helper", "shift")
.prefetch_related("shift__event__calendar")
.filter(shift__deleted=False, state=ShiftRegistration.RegState.REGISTERED)
.order_by("shift__start_at", "shift__room__name")
)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["page_range"] = context["paginator"].get_elided_page_range(
context["page_obj"].number
)
context["title"] = self.title
return context
def get_ordering(self):
return ("start_at", "room__name")
@login_required
def checkin(request, pk):
reg = get_object_or_404(ShiftRegistration, pk=pk)
if request.method == "POST":
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
def mark_as_failed(request, pk):
@ -324,33 +335,50 @@ def mark_as_failed(request, 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
def delete_shiftregistration(request, pk):
reg = get_object_or_404(ShiftRegistration, pk=pk)
spk = reg.shift.pk
if request.method == "POST":
reg.delete()
return redirect("team:shift", pk=spk)
@login_required
def incoming_messages(request):
p = Paginator(IncomingMessage.objects.order_by("read", "-created_at"), 10)
page = p.get_page(request.GET.get("page"))
return redirect("team:shift", pk=reg.shift.pk)
return render(
request,
"incoming_messages.html",
{
"num_unread": IncomingMessage.objects.filter(read=False).count(),
"page": page,
"page_range": p.get_elided_page_range(page.number),
},
"csrf_protect.html",
{"action": "Helfer*in abmelden", "button_text": "Abmelden", "reg": reg},
)
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
def incoming_message(request, 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):
token = get_object_or_404(RoomViewToken, pk=token)
room = token.room
return render(
request,
"room_registrations.html",
{
"room": get_object_or_404(RoomViewToken, pk=token).room,
},
{"room": room, "shifts": room.valid_shifts().order_by("start_at")},
)