show running shifts in free shifts, worklist and terminal

pull/1/head
parent 046189d93c
commit 10e642c4a3

@ -7,6 +7,7 @@ from .models import TeamBackup
from .models import Shift
from .forms import TeamBackupForm
from datetime import timedelta
from django.db.models import DateTimeField
# Create your views here.
@login_required
@ -16,9 +17,15 @@ def worklist(request):
)
shifts = (
Shift.with_reg_count()
.annotate(
end_at=ExpressionWrapper(
F("start_at") + F("duration"),
output_field=DateTimeField(),
)
)
.filter(
help_wanted,
start_at__gt=timezone.now(),
end_at__gte=timezone.now(),
deleted=False,
)
.order_by("start_at", "room_id")
@ -48,9 +55,15 @@ def terminal(request):
)
shifts = (
Shift.with_reg_count()
.annotate(
end_at=ExpressionWrapper(
F("start_at") + F("duration"),
output_field=DateTimeField(),
)
)
.filter(
help_wanted,
start_at__gt=timezone.now() - timedelta(minutes=20),
end_at__gte=timezone.now(),
deleted=False,
)
.order_by("start_at", "room_id")

@ -10,10 +10,9 @@ class NameField(forms.ModelChoiceField):
def label_from_instance(self, user):
return f"{user.name} ({(str(user.phone))[-3:]})"
class HelperShift(forms.Form):
helper = NameField(
label="Helfer*in", queryset=Helper.objects.order_by("name")
)
helper = NameField(label="Helfer*in", queryset=Helper.objects.order_by("name"))
class BulkMessage(forms.Form):

@ -141,14 +141,21 @@ class FreeShiftList(ShiftList):
) & Q(room__required_helpers__gt=F("reg_count"))
return (
Shift.with_reg_count()
.annotate(
end_at=ExpressionWrapper(
F("start_at") + F("duration"),
output_field=DateTimeField(),
)
)
.filter(
help_wanted,
start_at__gt=timezone.now(),
end_at__gte=timezone.now(),
deleted=False,
)
.order_by("start_at", "room_id")
)
@login_required
def checkin(request, pk):
reg = get_object_or_404(ShiftRegistration, pk=pk)

Loading…
Cancel
Save