Compare commits

..

3 Commits

Author SHA1 Message Date
Luca 2bb564ebce chore(fallback): do not show registration count for team-only shifts
continuous-integration/drone/push Build is passing Details
2025-05-18 14:48:00 +02:00
Luca 1dc92cba19 chore(fallback): mark team-only shifts as such in fallback shifts view
continuous-integration/drone/push Build is passing Details
2025-05-18 14:45:00 +02:00
Luca d466a744b9 refactor(fallback): move TradeForm into forms module 2025-05-18 13:39:51 +02:00
3 changed files with 29 additions and 23 deletions

View File

@ -0,0 +1,10 @@
from django import forms
class TradeForm(forms.Form):
assignment_id = forms.IntegerField(
widget=forms.NumberInput(attrs={"class": "input", "placeholder": "Schicht-ID"})
)
pin = forms.IntegerField(
widget=forms.PasswordInput(attrs={"class": "input", "placeholder": "Deine PIN"})
)

View File

@ -73,19 +73,20 @@ Diese Schichtzuteilung wurde maschinell erstellt und ist auch ohne Unterschrift
<td>{{ shift.start_at }}</td> <td>{{ shift.start_at }}</td>
<td>{{ shift.duration|duration }}</td> <td>{{ shift.duration|duration }}</td>
<td>{{ shift.room.name }} </td> <td>{{ shift.room.name }} </td>
<td>{{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}</td>
<td> <td>
{% for fa in shift.fallbackassignment_set.all %} {% if assignment.restricted %}
{% if fa.traded_to %} Nur Team
{{ fa.traded_to.name }} {% else %}
{% else %} {{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}
{{ fa.team_member.name }} {% endif %}
{% endif %}
{% if not forloop.last %}, {% endif %}
{% endfor %}
</td> </td>
<td> <td>
{% if shift.registration_count < shift.required_helpers|default:shift.room.required_helpers %} {% for fa in shift.fallbackassignment_set.all %}{% if fa.traded_to %}{{ fa.traded_to.name }}{% else %}{{ fa.team_member.name }}{% endif %}{% if not forloop.last %}, {% endif %}{% endfor %}
</td>
<td>
{% if assignment.restricted %}
<button class="button is-primary is-small mr-0" disabled>Nur Team</button>
{% elif shift.registration_count < shift.required_helpers|default:shift.room.required_helpers %}
<a class="button is-primary is-small mr-0" href="{% url 'shift' shift.id %}">Mithelfen</a> <a class="button is-primary is-small mr-0" href="{% url 'shift' shift.id %}">Mithelfen</a>
{% endif %} {% endif %}
</td> </td>

View File

@ -1,23 +1,15 @@
from base64 import urlsafe_b64decode from base64 import urlsafe_b64decode
from django import forms
from django.contrib import messages from django.contrib import messages
from django.contrib.auth.decorators import login_required from django.contrib.auth.decorators import login_required
from django.db.models import Count, Q from django.db.models import Count, Q
from django.db.models.functions import Coalesce
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect, render from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse from django.urls import reverse
from shiftregister.fallback.models import FallbackAssignment, TeamMember from .forms import TradeForm
from .models import FallbackAssignment, TeamMember
class TradeForm(forms.Form):
assignment_id = forms.IntegerField(
widget=forms.NumberInput(attrs={"class": "input", "placeholder": "Schicht-ID"})
)
pin = forms.IntegerField(
widget=forms.PasswordInput(attrs={"class": "input", "placeholder": "Deine PIN"})
)
def my_fallback_shifts(request, team_member_id): def my_fallback_shifts(request, team_member_id):
@ -70,11 +62,14 @@ def my_fallback_shifts(request, team_member_id):
messages.error(request, "Ungültige Schicht-ID") messages.error(request, "Ungültige Schicht-ID")
assignments = ( assignments = (
FallbackAssignment.objects.filter( FallbackAssignment.objects.select_related(
"shift__event__calendar", "traded_to", "team_member"
)
.annotate(restricted=Coalesce("shift__event__calendar__restricted", False))
.filter(
Q(team_member=team_member, traded_to__isnull=True) Q(team_member=team_member, traded_to__isnull=True)
| Q(traded_to=team_member) | Q(traded_to=team_member)
) )
.prefetch_related("shift", "traded_to", "team_member")
.order_by("shift__start_at") .order_by("shift__start_at")
) )