add signup links to shift list, only show unregisterd shifts
This commit is contained in:
parent
18b04a7102
commit
1e85c26f34
|
@ -5,7 +5,7 @@
|
|||
<h2>Freie Scchichten:</h2>
|
||||
<ul>
|
||||
{% for shift in free_shifts %}
|
||||
<li>{{ shift.room.name }} {{shift.start_at}}<a href="todo reg url">Mithelfen</a></li>
|
||||
<li>{{ shift.room.name }} {{shift.start_at}}<a href="{%url 'shift' shift.id%}">Mithelfen</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% endblock %}
|
|
@ -1,18 +1,25 @@
|
|||
from django.shortcuts import render, redirect, get_object_or_404
|
||||
from .models import Shift, LoginToken, Helper, ShiftRegistration
|
||||
import datetime
|
||||
from django.db.models import F, Count
|
||||
from django.db.models import F, Count, Q
|
||||
from .forms import RegisterForm, EmptyForm
|
||||
|
||||
def index(request):
|
||||
del request.session['last_seen_shift']
|
||||
if request.session.get('last_seen_shift'):
|
||||
del request.session['last_seen_shift']
|
||||
# dont show shifts starting in <60 minutes?
|
||||
# currently only sorts by date
|
||||
context = {}
|
||||
helper = None
|
||||
if request.session.get('token'):
|
||||
helper = LoginToken.objects.get(pk=request.session['token']).helper
|
||||
context['helper'] = helper
|
||||
free_shifts = Shift.objects.annotate(reg_count=Count('shiftregistration')).filter(start_at__gt=datetime.datetime.now(),
|
||||
room__required_helpers__gt=F('reg_count')).order_by('start_at')
|
||||
context = {'free_shifts': free_shifts}
|
||||
if request.session.get('token'):
|
||||
context['helper'] = LoginToken.objects.get(pk=request.session['token']).helper
|
||||
if helper:
|
||||
free_shifts = Shift.objects.annotate(reg_count=Count('shiftregistration')).filter(start_at__gt=datetime.datetime.now(),
|
||||
room__required_helpers__gt=F('reg_count')).filter( ~Q(shiftregistration__helper=helper)).order_by('start_at')
|
||||
context['free_shifts']= free_shifts
|
||||
return render(request, 'shiftlist.html', context)
|
||||
|
||||
def login(request, token):
|
||||
|
|
Loading…
Reference in New Issue