Compare commits

..

No commits in common. "5076d24dac3a69e61bcfc03547751d141af9a69b" and "a16a2d20e3614f2c0ab9b578db0baaaad88f069e" have entirely different histories.

7 changed files with 25 additions and 72 deletions

View File

@ -7,7 +7,7 @@
<em>gelöscht</em><br> <em>gelöscht</em><br>
{% endif %} {% endif %}
<strong>Ort:</strong> {{ shift.room.name }}<br> <strong>Ort:</strong> {{ shift.room.name }}<br>
<strong>Beginn:</strong> {{ shift.start_at }}{% with shift.start_at|night_from_to as night %}{% if night %} ({{ night }}){% endif %}{% endwith %}<br> <strong>Beginn:</strong> {{ shift.start_at }}<br>
<strong>Dauer:</strong> {{ shift.duration|duration }}<br> <strong>Dauer:</strong> {{ shift.duration|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 }}
</div> </div>

View File

@ -24,7 +24,7 @@
<div class="content"> <div class="content">
<p> <p>
<strong>Ort:</strong> <a href="{% url 'pages:view' 'map' %}#{{ shift.room.name|slugify }}">{{ shift.room.name }} 📍</a><br> <strong>Ort:</strong> <a href="{% url 'pages:view' 'map' %}#{{ shift.room.name|slugify }}">{{ shift.room.name }} 📍</a><br>
<strong>Beginn:</strong> {{ shift.start_at }}{% with shift.start_at|night_from_to as night %}{% if night %} ({{ night }}){% endif %}{% endwith %}<br> <strong>Beginn:</strong> {{ shift.start_at }}<br>
<strong>Dauer:</strong> {{ shift.duration|duration }}<br> <strong>Dauer:</strong> {{ shift.duration|duration }}<br>
<strong>Treffpunkt:</strong> {{ shift.room.meeting_location|linebreaksbr }}<br> <strong>Treffpunkt:</strong> {{ shift.room.meeting_location|linebreaksbr }}<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 }}

View File

@ -1,7 +1,4 @@
from datetime import datetime, timedelta
from django import template from django import template
from django.utils import timezone
register = template.Library() register = template.Library()
@ -14,18 +11,3 @@ def duration(value):
secs = secs % (hours * 60 * 60) secs = secs % (hours * 60 * 60)
minutes = secs // 60 minutes = secs // 60
return f"{hours}:{minutes:02d}h" return f"{hours}:{minutes:02d}h"
@register.filter(name="night_from_to")
def night_from_to(value):
if not isinstance(value, datetime):
raise ValueError("value must be a datetime object")
value = value.astimezone(timezone.get_current_timezone())
if value.hour < 6:
date = value.date()
days = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"]
return f"{days[(date-timedelta(days=1)).weekday()]}\u2192{days[date.weekday()]}"
return ""

View File

@ -14,35 +14,26 @@
<h4 class="subtitle">Schicht übernehmen</h4> <h4 class="subtitle">Schicht übernehmen</h4>
<form method="POST"> <form method="POST">
{% csrf_token %} {% csrf_token %}
<div class="field is-horizontal"> <div class="field has-addons">
<div class="field-body">
<div class="field">
{% with trade_form.assignment_id as field %}
<div class="control"> <div class="control">
{{ field }} {{ trade_form.assignment_id }}
</div> </div>
{% for error in field.errors %}
<p class="help is-danger">{{ error }}</p>
{% endfor %}
{% endwith %}
</div>
<div class="field">
{% with trade_form.pin as field %}
<div class="control"> <div class="control">
{{ field }} {{ trade_form.pin }}
</div> </div>
{% for error in field.errors %}
<p class="help is-danger">{{ error }}</p>
{% endfor %}
{% endwith %}
</div>
<div class="field">
<div class="control"> <div class="control">
<button type="submit" name="take_shift" class="button is-info">Übernehmen/Entfernen</button> <button type="submit" name="take_shift" class="button is-info">Übernehmen/Entfernen</button>
</div> </div>
</div> </div>
{% if form.errors %}
<div class="field">
{% for field in trade_form %}
{% for error in field.errors %}
<p class="help is-danger">{{ error }}</p>
{% endfor %}
{% endfor %}
</div> </div>
</div> {% endif %}
</form> </form>
</div> </div>
@ -79,14 +70,7 @@ Diese Schichtzuteilung wurde maschinell erstellt und ist auch ohne Unterschrift
{% with assignment.shift as shift %} {% with assignment.shift as shift %}
<tr{% if shift.registration_count == shift.required_helpers|default:shift.room.required_helpers or assignment.was_full %} class="has-text-grey" style="text-decoration: line-through;"{% endif %}> <tr{% if shift.registration_count == shift.required_helpers|default:shift.room.required_helpers or assignment.was_full %} class="has-text-grey" style="text-decoration: line-through;"{% endif %}>
<td>{{ assignment.id }} {% if assignment.traded_to %}*{% endif %}</td> <td>{{ assignment.id }} {% if assignment.traded_to %}*{% endif %}</td>
<td> <td>{{ shift.start_at }}</td>
{{ shift.start_at }}
{% with shift.start_at|night_from_to as night %}
{% if night %}
({{ night }})
{% endif %}
{% endwith %}
</td>
<td>{{ shift.duration|duration }}</td> <td>{{ shift.duration|duration }}</td>
<td>{{ shift.room.name }} </td> <td>{{ shift.room.name }} </td>
<td> <td>

View File

@ -1,5 +1,3 @@
{% load shift_extras %}
<a href="{% url 'team:shift' shift.pk %}"> <a href="{% url 'team:shift' shift.pk %}">
<div class="box"> <div class="box">
<div class="content"> <div class="content">
@ -7,7 +5,7 @@
<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 }}{% with shift.start_at|night_from_to as night %}{% if night %} ({{ night }}){% endif %}{% endwith %}<br> <strong>Beginn:</strong> {{ shift.start_at }}<br>
<strong>Dauer:</strong> {{ shift.duration }}<br> <strong>Dauer:</strong> {{ shift.duration }}<br>
{% if shift.event.calendar.restricted %} {% if shift.event.calendar.restricted %}
<strong>Nur Team:</strong> {{ shift.required_helpers|default:shift.room.required_helpers }} <strong>Nur Team:</strong> {{ shift.required_helpers|default:shift.room.required_helpers }}

View File

@ -1,7 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load shift_extras %}
{% block title %}{{ room.name }}{% endblock %} {% block title %}{{ room.name }}{% endblock %}
{% block everything %} {% block everything %}
@ -18,7 +16,7 @@
<tbody> <tbody>
{% for shift in shifts %} {% for shift in shifts %}
<tr> <tr>
<td>{{ shift.start_at }}{% with shift.start_at|night_from_to as night %}{% if night %} ({{ night }}){% endif %}{% endwith %}</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>
</tr> </tr>
{% endfor %} {% endfor %}

View File

@ -1,7 +1,5 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load shift_extras %}
{% block title %}Schichtdetails{% endblock %} {% block title %}Schichtdetails{% endblock %}
{% block content %} {% block content %}
@ -9,18 +7,11 @@
{% if shift.deleted %}(gelöscht) {% endif %} {% if shift.deleted %}(gelöscht) {% endif %}
<a href="{% url 'team:shift_room' shift.room.name %}">{{ shift.room.name }}</a> <a href="{% url 'team:shift_room' shift.room.name %}">{{ shift.room.name }}</a>
{{ shift.start_at }} {{ shift.start_at }}
{% with shift.start_at|night_from_to as night %}
{% if night %}
({{ night }})
{% endif %}
{% endwith %}
{% with shift.required_helpers|default:shift.room.required_helpers as required_helpers %}
{% if shift.event.calendar.restricted %} {% if shift.event.calendar.restricted %}
({{ required_helpers }} Teami{{ required_helpers|pluralize }}) ({{ shift.required_helpers|default:shift.room.required_helpers }} Teamis)
{% else %} {% else %}
({{ shift.registration_count }}/{{ required_helpers }}) ({{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }})
{% endif %} {% endif %}
{% endwith %}
</h3> </h3>
{% if shift.room.description %} {% if shift.room.description %}
<div class="content"> <div class="content">