Compare commits

..

No commits in common. "fac7d492d5ab65f5cbfe563a3dbbe79b2f8ecbf9" and "ceb6bf8528ff1df83494af9dd8afa983954b3c50" have entirely different histories.

3 changed files with 22 additions and 22 deletions

View File

@ -1,10 +0,0 @@
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

@ -75,12 +75,17 @@ Diese Schichtzuteilung wurde maschinell erstellt und ist auch ohne Unterschrift
<td>{{ shift.room.name }} </td>
<td>{{ shift.registration_count }}/{{ shift.required_helpers|default:shift.room.required_helpers }}</td>
<td>
{% 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 %}
{% 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 shift.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 %}
{% if 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>
{% endif %}
</td>

View File

@ -1,15 +1,23 @@
from base64 import urlsafe_b64decode
from django import forms
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.db.models import Count, Q
from django.db.models.functions import Coalesce
from django.http import HttpResponse
from django.shortcuts import get_object_or_404, redirect, render
from django.urls import reverse
from .forms import TradeForm
from .models import FallbackAssignment, TeamMember
from shiftregister.fallback.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):
@ -62,14 +70,11 @@ def my_fallback_shifts(request, team_member_id):
messages.error(request, "Ungültige Schicht-ID")
assignments = (
FallbackAssignment.objects.select_related(
"shift__event__calendar", "traded_to", "team_member"
)
.annotate(restricted=Coalesce("shift__event__calendar__restricted", False))
.filter(
FallbackAssignment.objects.filter(
Q(team_member=team_member, traded_to__isnull=True)
| Q(traded_to=team_member)
)
.prefetch_related("shift", "traded_to", "team_member")
.order_by("shift__start_at")
)