show running shifts in free shifts, worklist and terminal
This commit is contained in:
parent
046189d93c
commit
10e642c4a3
|
@ -149,9 +149,9 @@ class ShiftRegistration(models.Model):
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return f"{self.helper.name}: {self.shift}"
|
return f"{self.helper.name}: {self.shift}"
|
||||||
|
|
||||||
def is_checked_in(self):
|
def is_checked_in(self):
|
||||||
return self.state==self.RegState.CHECKED_IN
|
return self.state == self.RegState.CHECKED_IN
|
||||||
|
|
||||||
|
|
||||||
class Message(models.Model):
|
class Message(models.Model):
|
||||||
|
|
|
@ -7,6 +7,7 @@ from .models import TeamBackup
|
||||||
from .models import Shift
|
from .models import Shift
|
||||||
from .forms import TeamBackupForm
|
from .forms import TeamBackupForm
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
|
from django.db.models import DateTimeField
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
@login_required
|
@login_required
|
||||||
|
@ -16,9 +17,15 @@ def worklist(request):
|
||||||
)
|
)
|
||||||
shifts = (
|
shifts = (
|
||||||
Shift.with_reg_count()
|
Shift.with_reg_count()
|
||||||
|
.annotate(
|
||||||
|
end_at=ExpressionWrapper(
|
||||||
|
F("start_at") + F("duration"),
|
||||||
|
output_field=DateTimeField(),
|
||||||
|
)
|
||||||
|
)
|
||||||
.filter(
|
.filter(
|
||||||
help_wanted,
|
help_wanted,
|
||||||
start_at__gt=timezone.now(),
|
end_at__gte=timezone.now(),
|
||||||
deleted=False,
|
deleted=False,
|
||||||
)
|
)
|
||||||
.order_by("start_at", "room_id")
|
.order_by("start_at", "room_id")
|
||||||
|
@ -48,9 +55,15 @@ def terminal(request):
|
||||||
)
|
)
|
||||||
shifts = (
|
shifts = (
|
||||||
Shift.with_reg_count()
|
Shift.with_reg_count()
|
||||||
|
.annotate(
|
||||||
|
end_at=ExpressionWrapper(
|
||||||
|
F("start_at") + F("duration"),
|
||||||
|
output_field=DateTimeField(),
|
||||||
|
)
|
||||||
|
)
|
||||||
.filter(
|
.filter(
|
||||||
help_wanted,
|
help_wanted,
|
||||||
start_at__gt=timezone.now() - timedelta(minutes=20),
|
end_at__gte=timezone.now(),
|
||||||
deleted=False,
|
deleted=False,
|
||||||
)
|
)
|
||||||
.order_by("start_at", "room_id")
|
.order_by("start_at", "room_id")
|
||||||
|
|
|
@ -10,10 +10,9 @@ class NameField(forms.ModelChoiceField):
|
||||||
def label_from_instance(self, user):
|
def label_from_instance(self, user):
|
||||||
return f"{user.name} ({(str(user.phone))[-3:]})"
|
return f"{user.name} ({(str(user.phone))[-3:]})"
|
||||||
|
|
||||||
|
|
||||||
class HelperShift(forms.Form):
|
class HelperShift(forms.Form):
|
||||||
helper = NameField(
|
helper = NameField(label="Helfer*in", queryset=Helper.objects.order_by("name"))
|
||||||
label="Helfer*in", queryset=Helper.objects.order_by("name")
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
class BulkMessage(forms.Form):
|
class BulkMessage(forms.Form):
|
||||||
|
|
|
@ -11,5 +11,5 @@ urlpatterns = [
|
||||||
path("shift/<int:pk>", views.shift_detail, name="shift"),
|
path("shift/<int:pk>", views.shift_detail, name="shift"),
|
||||||
path("helper/<int:pk>", views.HelperDetail.as_view(), name="helper"),
|
path("helper/<int:pk>", views.HelperDetail.as_view(), name="helper"),
|
||||||
path("message/", views.bulk_message, name="bulk_message"),
|
path("message/", views.bulk_message, name="bulk_message"),
|
||||||
path("checkin/<int:pk>", views.checkin, name="checkin" ),
|
path("checkin/<int:pk>", views.checkin, name="checkin"),
|
||||||
]
|
]
|
||||||
|
|
|
@ -141,17 +141,24 @@ class FreeShiftList(ShiftList):
|
||||||
) & Q(room__required_helpers__gt=F("reg_count"))
|
) & Q(room__required_helpers__gt=F("reg_count"))
|
||||||
return (
|
return (
|
||||||
Shift.with_reg_count()
|
Shift.with_reg_count()
|
||||||
|
.annotate(
|
||||||
|
end_at=ExpressionWrapper(
|
||||||
|
F("start_at") + F("duration"),
|
||||||
|
output_field=DateTimeField(),
|
||||||
|
)
|
||||||
|
)
|
||||||
.filter(
|
.filter(
|
||||||
help_wanted,
|
help_wanted,
|
||||||
start_at__gt=timezone.now(),
|
end_at__gte=timezone.now(),
|
||||||
deleted = False,
|
deleted=False,
|
||||||
)
|
)
|
||||||
.order_by("start_at", "room_id")
|
.order_by("start_at", "room_id")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def checkin(request, pk):
|
def checkin(request, pk):
|
||||||
reg = get_object_or_404(ShiftRegistration, pk=pk)
|
reg = get_object_or_404(ShiftRegistration, pk=pk)
|
||||||
reg.state = reg.RegState.CHECKED_IN
|
reg.state = reg.RegState.CHECKED_IN
|
||||||
reg.save()
|
reg.save()
|
||||||
return redirect("team:shift", pk=reg.shift.pk)
|
return redirect("team:shift", pk=reg.shift.pk)
|
||||||
|
|
Loading…
Reference in New Issue