|
|
|
@ -2,6 +2,7 @@ from django.shortcuts import render, redirect, get_object_or_404
|
|
|
|
|
from .models import Shift, LoginToken, Helper, ShiftRegistration
|
|
|
|
|
from django.db import transaction
|
|
|
|
|
from django.db.models import F, Count, Q, ExpressionWrapper
|
|
|
|
|
from django.core.cache import cache
|
|
|
|
|
from .forms import RegisterForm, EmptyForm, AstaForm
|
|
|
|
|
from django.db.models.fields import DateTimeField
|
|
|
|
|
from datetime import timedelta
|
|
|
|
@ -21,8 +22,13 @@ def index(request):
|
|
|
|
|
if request.session.get("last_seen_shift"):
|
|
|
|
|
del request.session["last_seen_shift"]
|
|
|
|
|
|
|
|
|
|
days = cache.get("event_days")
|
|
|
|
|
if not days:
|
|
|
|
|
days = Shift.objects.filter(deleted=False).datetimes("start_at", "day").all()
|
|
|
|
|
cache.set("event_days", days)
|
|
|
|
|
|
|
|
|
|
context = {
|
|
|
|
|
"days": Shift.objects.filter(deleted=False).datetimes("start_at", "day"),
|
|
|
|
|
"days": days,
|
|
|
|
|
"enable_asta": global_preferences["helper__enable_asta"],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -58,7 +64,7 @@ def index(request):
|
|
|
|
|
deleted=False,
|
|
|
|
|
)
|
|
|
|
|
.order_by("start_at")
|
|
|
|
|
for day in Shift.objects.datetimes("start_at", "day")
|
|
|
|
|
for day in days
|
|
|
|
|
)
|
|
|
|
|
if request.helper:
|
|
|
|
|
free_shifts = (
|
|
|
|
@ -175,7 +181,7 @@ def register(request):
|
|
|
|
|
|
|
|
|
|
@event_state
|
|
|
|
|
def shift(request, shiftid):
|
|
|
|
|
shift = get_object_or_404(Shift, pk=shiftid)
|
|
|
|
|
shift = get_object_or_404(Shift.with_reg_count(), pk=shiftid)
|
|
|
|
|
helper = request.helper
|
|
|
|
|
context = {
|
|
|
|
|
"enable_asta": global_preferences["helper__enable_asta"],
|
|
|
|
|