feat: make team-only shifts distinguishable in backend
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Luca 2025-05-19 22:32:48 +02:00
parent 8e9ef718b8
commit a16a2d20e3
3 changed files with 19 additions and 17 deletions

View File

@ -7,7 +7,11 @@
<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>
{% if shift.event.calendar.restricted %}
<strong>Nur Team:</strong> {{ shift.required_helpers|default:shift.room.required_helpers }}
{% else %}
<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 }}
{% endif %}
{% 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 %}

View File

@ -6,7 +6,12 @@
<h3 class="title is-spaced"> <h3 class="title is-spaced">
{% 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.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}) {{ shift.start_at }}
{% if shift.event.calendar.restricted %}
({{ shift.required_helpers|default:shift.room.required_helpers }} Teamis)
{% else %}
({{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }})
{% endif %}
</h3> </h3>
{% if shift.room.description %} {% if shift.room.description %}
<div class="content"> <div class="content">
@ -53,10 +58,10 @@
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
{% if shift.event.fallbackassignment_set.count > 0 %} {% if shift.fallbackassignment_set.count > 0 %}
<h5 class="subtitle">Teammitglieder</h5> <h5 class="subtitle">Teammitglieder</h5>
<div class="columns is-multiline"> <div class="columns is-multiline">
{% for fallback in shift.event.fallbackassignment_set.all %} {% for fallback in shift.fallbackassignment_set.all %}
<div class="column is-one-quarter"> <div class="column is-one-quarter">
<div class="box{% if fallback.was_full %} has-text-grey" style="text-decoration: line-through;{% endif %}"> <div class="box{% if fallback.was_full %} has-text-grey" style="text-decoration: line-through;{% endif %}">
{% if fallback.traded_to %} {% if fallback.traded_to %}
@ -69,6 +74,7 @@
{% endfor %} {% endfor %}
</div> </div>
{% endif %} {% endif %}
{% if not shift.event.calendar.restricted %}
<h5 class="subtitle">Helfi eintragen</h5> <h5 class="subtitle">Helfi eintragen</h5>
<form action="" method="post"> <form action="" method="post">
{% csrf_token %} {% csrf_token %}
@ -97,4 +103,5 @@
{% endfor %} {% endfor %}
<button class="button is-link" type="submit">Hinzufügen</button> <button class="button is-link" type="submit">Hinzufügen</button>
</form> </form>
{% endif %}
{% endblock %} {% endblock %}

View File

@ -45,17 +45,9 @@ def shift_overview(request):
context = {} context = {}
context["running_shifts"] = ( context["running_shifts"] = (
Shift.all_objects.with_reg_count() Shift.all_objects.with_reg_count()
.prefetch_related("event__calendar") .select_related("event__calendar")
.annotate( .annotate(
checkin_count=Count( checkin_count=checkin_count,
Case(
When(
shiftregistration__state=ShiftRegistration.RegState.CHECKED_IN,
then=1,
),
output_field=models.IntegerField(),
)
),
end_at=ExpressionWrapper( end_at=ExpressionWrapper(
F("start_at") + F("duration"), output_field=DateTimeField() F("start_at") + F("duration"), output_field=DateTimeField()
), ),
@ -66,7 +58,7 @@ def shift_overview(request):
context["next_shifts"] = ( context["next_shifts"] = (
Shift.all_objects.with_reg_count() Shift.all_objects.with_reg_count()
.prefetch_related("event__calendar") .select_related("event__calendar")
.annotate(checkin_count=checkin_count) .annotate(checkin_count=checkin_count)
.filter( .filter(
start_at__gt=timezone.now(), start_at__gt=timezone.now(),
@ -81,7 +73,7 @@ def shift_overview(request):
lambda x: x is not None, lambda x: x is not None,
( (
Shift.all_objects.with_reg_count() Shift.all_objects.with_reg_count()
.prefetch_related("event__calendar") .select_related("event__calendar")
.filter(room=room, start_at__gt=timezone.now(), deleted=False) .filter(room=room, start_at__gt=timezone.now(), deleted=False)
.order_by("start_at") .order_by("start_at")
.first() .first()
@ -284,8 +276,7 @@ class CheckinList(LoginRequiredMixin, ListView):
def get_queryset(self): def get_queryset(self):
return ( return (
ShiftRegistration.objects.select_related("helper", "shift") ShiftRegistration.objects.select_related("helper", "shift__event__calendar")
.prefetch_related("shift__event__calendar")
.filter(shift__deleted=False, state=ShiftRegistration.RegState.REGISTERED) .filter(shift__deleted=False, state=ShiftRegistration.RegState.REGISTERED)
.order_by("shift__start_at", "shift__room__name") .order_by("shift__start_at", "shift__room__name")
) )