Date range selection on session view
This commit is contained in:
@@ -855,6 +855,10 @@ class PlannedSession(models.Model):
|
|||||||
choices=verificationchoices
|
choices=verificationchoices
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# 0 = incomplete, 1 = complete, >1 = partial (details could
|
||||||
|
# be defined later)
|
||||||
|
sessioncompleted = models.IntegerField(default=0)
|
||||||
|
|
||||||
team = models.ManyToManyField(Team,blank=True)
|
team = models.ManyToManyField(Team,blank=True)
|
||||||
rower = models.ManyToManyField(Rower,blank=True)
|
rower = models.ManyToManyField(Rower,blank=True)
|
||||||
|
|
||||||
|
|||||||
@@ -6,17 +6,40 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="grid_12 alpha">
|
<div class="grid_12 alpha">
|
||||||
{% include "planningbuttons.html" %}
|
{% include "planningbuttons.html" %}
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div id="left" class="grid_6 alpha">
|
<div class="grid_6 alpha">
|
||||||
<p>Placeholder text</p>
|
<h1>Plan for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||||
</div>
|
</div>
|
||||||
<div id="right" class="grid_6 omega">
|
<div id="timeperiod" class="grid_2 dropdown">
|
||||||
<h1>Plan</h1>
|
<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>
|
<p>
|
||||||
Click on session name to view
|
Click on session name to view
|
||||||
</p>
|
</p>
|
||||||
<table class="listtable shortpadded">
|
<table width="80%" class="listtable shortpadded">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>After</th>
|
<th>After</th>
|
||||||
@@ -24,6 +47,9 @@
|
|||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Value</th>
|
<th>Value</th>
|
||||||
<th> </th>
|
<th> </th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>Done</th>
|
||||||
|
<th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@@ -42,6 +68,7 @@
|
|||||||
</td>
|
</td>
|
||||||
<td> {{ ps.sessionvalue }} </td>
|
<td> {{ ps.sessionvalue }} </td>
|
||||||
<td> {{ ps.sessionunit }} </td>
|
<td> {{ ps.sessionunit }} </td>
|
||||||
|
<td> {{ ps.sessiontype }} </td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|||||||
@@ -402,6 +402,8 @@ urlpatterns = [
|
|||||||
url(r'^sessions/(?P<id>\d+)/deleteconfirm$',views.plannedsession_deleteconfirm_view),
|
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/(?P<id>\d+)/delete$',views.plannedsession_delete_view),
|
||||||
url(r'^sessions/?$',views.plannedsessions_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),
|
url(r'^sessions/(?P<timeperiod>[\w\ ]+.*)$',views.plannedsessions_view),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@@ -11758,7 +11758,10 @@ def plannedsessions_view(request,timeperiod='today',rowerid=0):
|
|||||||
if rowerid==0:
|
if rowerid==0:
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
else:
|
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):
|
if not checkaccessuser(request.user,r):
|
||||||
raise Http404("You don't have access to this plan")
|
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)
|
startdate = today.replace(day=1)
|
||||||
enddate = startdate+timezone.timedelta(days=32)
|
enddate = startdate+timezone.timedelta(days=32)
|
||||||
enddate = enddate.replace(day=1)
|
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:
|
else:
|
||||||
startdate = datetime.date.today()
|
startdate = datetime.date.today()
|
||||||
enddate = 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),
|
'teams':get_my_teams(request.user),
|
||||||
'plannedsessions':sps,
|
'plannedsessions':sps,
|
||||||
|
'rower':r,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user