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

@@ -855,6 +855,10 @@ class PlannedSession(models.Model):
choices=verificationchoices
)
# 0 = incomplete, 1 = complete, >1 = partial (details could
# be defined later)
sessioncompleted = models.IntegerField(default=0)
team = models.ManyToManyField(Team,blank=True)
rower = models.ManyToManyField(Rower,blank=True)

View File

@@ -6,17 +6,40 @@
{% block content %}
<div class="grid_12 alpha">
{% include "planningbuttons.html" %}
</div>
<div id="left" class="grid_6 alpha">
<p>Placeholder text</p>
<div class="grid_6 alpha">
<h1>Plan for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
</div>
<div id="right" class="grid_6 omega">
<h1>Plan</h1>
<div id="timeperiod" class="grid_2 dropdown">
<button class="grid_2 alpha button gray small dropbtn">Time Period</button>
<div class="dropdown-content">
<a class="button gray small alpha"
href="/rowers/sessions/today/rower/{{ rower.id }}">
Today
</a>
<a class="button gray small alpha"
href="/rowers/sessions/thisweek/rower/{{ rower.id }}">
This Week
</a>
<a class="button gray small alpha"
href="/rowers/sessions/thismonth/rower/{{ rower.id }}">
This Month
</a>
<a class="button gray small alpha"
href="/rowers/sessions/lastweek/rower/{{ rower.id }}">
Last Week
</a>
<a class="button gray small alpha"
href="/rowers/sessions/lastmonth/rower/{{ rower.id }}">
Last Month
</a>
</div>
</div>
<div class="grid_12 alpha">
<p>
Click on session name to view
</p>
<table class="listtable shortpadded">
<table width="80%" class="listtable shortpadded">
<thead>
<tr>
<th>After</th>
@@ -24,6 +47,9 @@
<th>Name</th>
<th>Value</th>
<th>&nbsp;</th>
<th>Type</th>
<th>Done</th>
<th>
</tr>
</thead>
<tbody>
@@ -42,6 +68,7 @@
</td>
<td> {{ ps.sessionvalue }} </td>
<td> {{ ps.sessionunit }} </td>
<td> {{ ps.sessiontype }} </td>
</tr>
{% endfor %}
</tbody>

View File

@@ -402,6 +402,8 @@ urlpatterns = [
url(r'^sessions/(?P<id>\d+)/deleteconfirm$',views.plannedsession_deleteconfirm_view),
url(r'^sessions/(?P<id>\d+)/delete$',views.plannedsession_delete_view),
url(r'^sessions/?$',views.plannedsessions_view),
url(r'^sessions/rower/(?P<rowerid>\d+)$',views.plannedsessions_view),
url(r'^sessions/(?P<timeperiod>[\w\ ]+.*)/rower/(?P<rowerid>\d+)$',views.plannedsessions_view),
url(r'^sessions/(?P<timeperiod>[\w\ ]+.*)$',views.plannedsessions_view),
]

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,
})