feat: show previous and current day of week for shifts between 0 and 6
This commit is contained in:
parent
a16a2d20e3
commit
4380f47302
|
@ -7,7 +7,7 @@
|
|||
<em>gelöscht</em><br>
|
||||
{% endif %}
|
||||
<strong>Ort:</strong> {{ shift.room.name }}<br>
|
||||
<strong>Beginn:</strong> {{ shift.start_at }}<br>
|
||||
<strong>Beginn:</strong> {{ shift.start_at }}{% with shift.start_at|night_from_to as night %}{% if night %} ({{ night }}){% endif %}{% endwith %}<br>
|
||||
<strong>Dauer:</strong> {{ shift.duration|duration }}<br>
|
||||
<strong>Belegung:</strong> {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
|
||||
</div>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
<div class="content">
|
||||
<p>
|
||||
<strong>Ort:</strong> <a href="{% url 'pages:view' 'map' %}#{{ shift.room.name|slugify }}">{{ shift.room.name }} 📍</a><br>
|
||||
<strong>Beginn:</strong> {{ shift.start_at }}<br>
|
||||
<strong>Beginn:</strong> {{ shift.start_at }}{% with shift.start_at|night_from_to as night %}{% if night %} ({{ night }}){% endif %}{% endwith %}<br>
|
||||
<strong>Dauer:</strong> {{ shift.duration|duration }}<br>
|
||||
<strong>Treffpunkt:</strong> {{ shift.room.meeting_location|linebreaksbr }}<br>
|
||||
<strong>Belegung:</strong> {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
from datetime import datetime, timedelta
|
||||
|
||||
from django import template
|
||||
from django.utils import timezone
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
@ -11,3 +14,18 @@ def duration(value):
|
|||
secs = secs % (hours * 60 * 60)
|
||||
minutes = secs // 60
|
||||
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 ""
|
||||
|
|
|
@ -70,7 +70,14 @@ Diese Schichtzuteilung wurde maschinell erstellt und ist auch ohne Unterschrift
|
|||
{% 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 %}>
|
||||
<td>{{ assignment.id }} {% if assignment.traded_to %}*{% endif %}</td>
|
||||
<td>{{ shift.start_at }}</td>
|
||||
<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.room.name }} </td>
|
||||
<td>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
{% load shift_extras %}
|
||||
|
||||
<a href="{% url 'team:shift' shift.pk %}">
|
||||
<div class="box">
|
||||
<div class="content">
|
||||
|
@ -5,7 +7,7 @@
|
|||
<em>gelöscht</em><br>
|
||||
{% endif %}
|
||||
<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 }}{% with shift.start_at|night_from_to as night %}{% if night %} ({{ night }}){% endif %}{% endwith %}<br>
|
||||
<strong>Dauer:</strong> {{ shift.duration }}<br>
|
||||
{% if shift.event.calendar.restricted %}
|
||||
<strong>Nur Team:</strong> {{ shift.required_helpers|default:shift.room.required_helpers }}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load shift_extras %}
|
||||
|
||||
{% block title %}{{ room.name }}{% endblock %}
|
||||
|
||||
{% block everything %}
|
||||
|
@ -16,7 +18,7 @@
|
|||
<tbody>
|
||||
{% for shift in shifts %}
|
||||
<tr>
|
||||
<td>{{ shift.start_at }}</td>
|
||||
<td>{{ shift.start_at }}{% with shift.start_at|night_from_to as night %}{% if night %} ({{ night }}){% endif %}{% endwith %}</td>
|
||||
<td>{% for reg in shift.valid_registrations.all %}{{ reg.helper.name }}{% if not forloop.last %}, {% endif %}{% endfor %}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% load shift_extras %}
|
||||
|
||||
{% block title %}Schichtdetails{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
@ -7,6 +9,11 @@
|
|||
{% if shift.deleted %}(gelöscht) {% endif %}
|
||||
<a href="{% url 'team:shift_room' shift.room.name %}">{{ shift.room.name }}</a>
|
||||
{{ shift.start_at }}
|
||||
{% with shift.start_at|night_from_to as night %}
|
||||
{% if night %}
|
||||
({{ night }})
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
{% if shift.event.calendar.restricted %}
|
||||
({{ shift.required_helpers|default:shift.room.required_helpers }} Teamis)
|
||||
{% else %}
|
||||
|
|
Loading…
Reference in New Issue