history post to get plus predefined links
This commit is contained in:
@@ -5,20 +5,31 @@
|
||||
{% block title %}Rowsandall {% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<h1>History for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||
|
||||
<ul class="main-content">
|
||||
<link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.css" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css" type="text/css" />
|
||||
<link rel="stylesheet" href="https://cdn.pydata.org/bokeh/release/bokeh-widgets-1.0.4.min.css" type="text/css" />
|
||||
<script async="true" src="https://cdn.pydata.org/bokeh/release/bokeh-1.0.4.min.js"></script>
|
||||
<li class="grid_2">
|
||||
<h1>History for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ lastseven|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 7 days</a>
|
||||
|
||||
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ lastfourteen|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 14 days</a>
|
||||
|
||||
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ last28|date:"Y-m-d" }}&workouttype={{ workouttype }}">Past 28 days</a>
|
||||
|
||||
<a href="/rowers/history/?enddate={{ today|date:"Y-m-d" }}&startdate={{ firstmay|date:"Y-m-d" }}&workouttype={{ workouttype }}">Current Concept2 Season</a>
|
||||
</li>
|
||||
<li class="grid_2">
|
||||
<p>
|
||||
<form enctype="multipart/form-data" method="post">
|
||||
{% csrf_token %}
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<input type="submit" value="Submit">
|
||||
</form>
|
||||
<form enctype="multipart/form-data" method="get">
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<input type="submit" value="Submit"/>
|
||||
</form>
|
||||
</p>
|
||||
<h2>All workouts</h2>
|
||||
|
||||
|
||||
@@ -4658,32 +4658,32 @@ class AlertDelete(DeleteView):
|
||||
def history_view(request,userid=0):
|
||||
r = getrequestrower(request,userid=userid)
|
||||
|
||||
form = HistorySelectForm()
|
||||
|
||||
usertimezone = pytz.timezone(r.defaulttimezone)
|
||||
|
||||
activity_enddate = timezone.now()
|
||||
activity_enddate = activity_enddate.replace(hour=23,minute=59,second=59).astimezone(usertimezone)
|
||||
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
||||
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||
if request.GET.get('startdate'):
|
||||
startdate,enddate = get_dates_timeperiod(request)
|
||||
activity_startdate = datetime.datetime(
|
||||
startdate.year,startdate.month,startdate.day
|
||||
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||
activity_enddate = datetime.datetime(
|
||||
enddate.year,enddate.month,enddate.day
|
||||
).replace(hour=23,minute=59,second=59).astimezone(usertimezone)
|
||||
else:
|
||||
activity_enddate = timezone.now()
|
||||
activity_enddate = activity_enddate.replace(hour=23,minute=59,second=59).astimezone(usertimezone)
|
||||
activity_startdate = activity_enddate-datetime.timedelta(days=15)
|
||||
activity_startdate = activity_startdate.replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||
|
||||
typeselect = 'All'
|
||||
if request.GET.get('workouttype'):
|
||||
typeselect = request.GET.get('workouttype')
|
||||
|
||||
if request.method=='POST':
|
||||
form = HistorySelectForm(request.POST)
|
||||
if form.is_valid():
|
||||
startdate = form.cleaned_data['startdate']
|
||||
enddate = form.cleaned_data['enddate']
|
||||
typeselect = form.cleaned_data['workouttype']
|
||||
activity_startdate = datetime.datetime(
|
||||
startdate.year,startdate.month,startdate.day
|
||||
).replace(hour=0,minute=0,second=0).astimezone(usertimezone)
|
||||
activity_enddate = datetime.datetime(
|
||||
enddate.year,enddate.month,enddate.day
|
||||
).replace(hour=23,minute=59,second=59).astimezone(usertimezone)
|
||||
|
||||
|
||||
|
||||
if typeselect not in mytypes.checktypes:
|
||||
typeselect = 'All'
|
||||
|
||||
form = HistorySelectForm(initial={'startdate':activity_startdate,
|
||||
'enddate':activity_enddate,
|
||||
'workouttype':typeselect})
|
||||
|
||||
g_workouts = Workout.objects.filter(
|
||||
user=r,
|
||||
@@ -4795,6 +4795,15 @@ def history_view(request,userid=0):
|
||||
},
|
||||
]
|
||||
|
||||
lastseven = timezone.now()-datetime.timedelta(days=7)
|
||||
lastfourteen = timezone.now()-datetime.timedelta(days=14)
|
||||
last28 = timezone.now()-datetime.timedelta(days=28)
|
||||
today = timezone.now()
|
||||
|
||||
firstmay = datetime.datetime(year=today.year,month=5,day=1).astimezone(usertimezone)
|
||||
if firstmay>today:
|
||||
firstmay = datetime.datetime(year=today.year-1,month=5,day=1)
|
||||
|
||||
return render(request,'history.html',
|
||||
{
|
||||
'rower':r,
|
||||
@@ -4805,4 +4814,12 @@ def history_view(request,userid=0):
|
||||
'totalscript':totalscript,
|
||||
'totaldiv':totaldiv,
|
||||
'form':form,
|
||||
'startdate':activity_startdate,
|
||||
'enddate':activity_enddate,
|
||||
'lastseven':lastseven,
|
||||
'lastfourteen':lastfourteen,
|
||||
'last28':last28,
|
||||
'today':today,
|
||||
'workouttype':typeselect,
|
||||
'firstmay':firstmay,
|
||||
})
|
||||
|
||||
@@ -467,6 +467,7 @@ def getrequestrower(request,rowerid=0,userid=0,notpermanent=False):
|
||||
raise Http404("Rower doesn't exist")
|
||||
|
||||
if r.user == request.user:
|
||||
request.session['rowerid'] = r.id
|
||||
return r
|
||||
|
||||
if userid != 0 and not is_rower_team_member(request.user,u.rower):
|
||||
@@ -476,6 +477,7 @@ def getrequestrower(request,rowerid=0,userid=0,notpermanent=False):
|
||||
if notpermanent == False:
|
||||
request.session['rowerid'] = r.id
|
||||
|
||||
request.session['rowerid'] = r.id
|
||||
return r
|
||||
|
||||
def getrequestplanrower(request,rowerid=0,userid=0,notpermanent=False):
|
||||
|
||||
Reference in New Issue
Block a user