Private
Public Access
1
0

Date range selection on session view

This commit is contained in:
Sander Roosendaal
2018-02-06 21:00:59 +01:00
parent 7bb91c33c7
commit d3448c66f1
4 changed files with 55 additions and 7 deletions

View File

@@ -11758,7 +11758,10 @@ def plannedsessions_view(request,timeperiod='today',rowerid=0):
if rowerid==0:
r = getrower(request.user)
else:
r = getrower(id=rowerid)
try:
r = Rower.objects.get(id=rowerid)
except Rower.DoesNotExist:
raise Http404("This rower doesn't exist")
if not checkaccessuser(request.user,r):
raise Http404("You don't have access to this plan")
@@ -11778,6 +11781,17 @@ def plannedsessions_view(request,timeperiod='today',rowerid=0):
startdate = today.replace(day=1)
enddate = startdate+timezone.timedelta(days=32)
enddate = enddate.replace(day=1)
elif timeperiod=='lastweek':
today = datetime.date.today()
enddate = today-timezone.timedelta(days=today.weekday())
startdate = enddate-timezone.timedelta(days=7)
elif timeperiod=='lastmonth':
today = datetime.date.today()
startdate = today.replace(day=1)
startdate = startdate-timezone.timedelta(days=3)
startdate = startdate.replace(day=1)
enddate = startdate+timezone.timedelta(days=32)
enddate = enddate.replace(day=1)
else:
startdate = datetime.date.today()
enddate = datetime.date.today()
@@ -11790,6 +11804,7 @@ def plannedsessions_view(request,timeperiod='today',rowerid=0):
{
'teams':get_my_teams(request.user),
'plannedsessions':sps,
'rower':r,
})