multicompare view line 330 urls.py
This commit is contained in:
@@ -1,10 +1,10 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "newbase.html" %}
|
||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
{% load rowerfilters %}
|
{% load rowerfilters %}
|
||||||
|
|
||||||
{% block title %}View Comparison {% endblock %}
|
{% block title %}View Comparison {% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block main %}
|
||||||
|
|
||||||
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
<script type="text/javascript" src="/static/js/bokeh-0.12.3.min.js"></script>
|
||||||
<script async="true" type="text/javascript">
|
<script async="true" type="text/javascript">
|
||||||
@@ -13,58 +13,31 @@
|
|||||||
|
|
||||||
{{ interactiveplot |safe }}
|
{{ interactiveplot |safe }}
|
||||||
|
|
||||||
<script>
|
<h1>Interactive Comparison</h1>
|
||||||
// Set things up to resize the plot on a window resize. You can play with
|
<ul class="main-content">
|
||||||
// the arguments of resize_width_height() to change the plot's behavior.
|
<li class="grid_2">
|
||||||
var plot_resize_setup = function () {
|
<form enctype="multipart/form-data" action="/rowers/multi-compare" method="post">
|
||||||
var plotid = Object.keys(Bokeh.index)[0]; // assume we have just one plot
|
{% csrf_token %}
|
||||||
var plot = Bokeh.index[plotid];
|
<table>
|
||||||
var plotresizer = function() {
|
{{ chartform.as_table }}
|
||||||
// arguments: use width, use height, maintain aspect ratio
|
</table>
|
||||||
plot.resize_width_height(true, false, false);
|
|
||||||
};
|
|
||||||
window.addEventListener('resize', plotresizer);
|
|
||||||
plotresizer();
|
|
||||||
};
|
|
||||||
window.addEventListener('load', plot_resize_setup);
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
<style>
|
|
||||||
/* Need this to get the page in "desktop mode"; not having an infinite height.*/
|
|
||||||
html, body {height: 100%; margin:5px;}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
|
|
||||||
<div class="grid_12 alpha">
|
|
||||||
{% include "teambuttons.html" with teamid=teamid team=team %}
|
|
||||||
</div>
|
|
||||||
<div class="grid_12">
|
|
||||||
<div id="workouts" class="grid_8 alpha">
|
|
||||||
<h1>Interactive Comparison</h1>
|
|
||||||
</div>
|
|
||||||
<div class="grid_4 omega">
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/multi-compare" method="post">
|
|
||||||
{% csrf_token %}
|
|
||||||
<table>
|
|
||||||
{{ chartform.as_table }}
|
|
||||||
</table>
|
|
||||||
<div class="grid_1 prefix_2 suffix_1">
|
|
||||||
<p>
|
<p>
|
||||||
<input name='workoutselectform' class="button green" type="submit" value="Submit">
|
<input name='workoutselectform' class="button green" type="submit" value="Submit">
|
||||||
</p>
|
</p>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
<li class="grid_4">
|
||||||
|
|
||||||
|
<div>
|
||||||
|
{{ the_div|safe }}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</li>
|
||||||
</div>
|
</ul>
|
||||||
</div>
|
|
||||||
<div class="grid_12 alpha">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<div id="theplot" class="grid_12 alpha flexplot">
|
|
||||||
{{ the_div|safe }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_workouts.html' %}
|
||||||
|
{% endblock %}
|
||||||
|
|||||||
@@ -29,7 +29,9 @@
|
|||||||
|
|
||||||
hidden.hide();
|
hidden.hide();
|
||||||
|
|
||||||
|
if (modality.val() == 'water') {
|
||||||
|
hidden.show();
|
||||||
|
}
|
||||||
|
|
||||||
// Setup an event listener for when the state of the
|
// Setup an event listener for when the state of the
|
||||||
// checkbox changes.
|
// checkbox changes.
|
||||||
@@ -68,12 +70,25 @@
|
|||||||
|
|
||||||
|
|
||||||
<ul class="main-content">
|
<ul class="main-content">
|
||||||
|
<li class="grid_4">
|
||||||
|
<p>Select two or more workouts on the left, set your plot settings,
|
||||||
|
and press submit</p>
|
||||||
|
<p>
|
||||||
|
You can use the date and search forms to search through all
|
||||||
|
workouts from this team.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
TIP: Agree with your team members to put tags (e.g. '8x500m')
|
||||||
|
in the notes section of
|
||||||
|
your workouts. That makes it easy to search.
|
||||||
|
</p>
|
||||||
|
</li>
|
||||||
<li class="grid_2 maxheight">
|
<li class="grid_2 maxheight">
|
||||||
|
{% if workouts %}
|
||||||
<form enctype="multipart/form-data" action="/rowers/multi-compare" method="post">
|
<form enctype="multipart/form-data" action="/rowers/multi-compare" method="post">
|
||||||
{% if workouts %}
|
|
||||||
|
|
||||||
<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
|
<input type="checkbox" onClick="toggle(this)" /> Toggle All<br/>
|
||||||
|
|
||||||
<table width="100%" class="listtable">
|
<table width="100%" class="listtable">
|
||||||
{{ form.as_table }}
|
{{ form.as_table }}
|
||||||
</table>
|
</table>
|
||||||
@@ -83,54 +98,42 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
</li>
|
</li>
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
|
<p>
|
||||||
|
{% csrf_token %}
|
||||||
|
<table>
|
||||||
|
{{ chartform.as_table }}
|
||||||
|
</table>
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<input name="chartform" class="button green" type="submit" value="Submit">
|
||||||
|
</p>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
<li class="grid_2">
|
||||||
|
{% if team %}
|
||||||
|
<form enctype="multipart/form-data"
|
||||||
|
action="/rowers/team-compare-select/team/{{ team.id }}"
|
||||||
|
method="post">
|
||||||
|
{% else %}
|
||||||
|
<form enctype="multipart/form-data"
|
||||||
|
action="/rowers/team-compare-select/"
|
||||||
|
method="post">
|
||||||
|
{% endif %}
|
||||||
|
<table>
|
||||||
|
{{ dateform.as_table }}
|
||||||
|
</table>
|
||||||
|
<table>
|
||||||
|
{{ modalityform.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
<p>
|
<p>
|
||||||
{% csrf_token %}
|
<input name='modalityform' class="button green" type="submit" value="Submit">
|
||||||
<table>
|
|
||||||
{{ chartform.as_table }}
|
|
||||||
</table>
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
<input name='workoutselectform' class="button green" type="submit" value="Submit">
|
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
{% if team %}
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/team-compare-select/team/{{ team.id }}/" method="post">
|
|
||||||
{% else %}
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/team-compare-select/" method="post">
|
|
||||||
{% endif %}
|
|
||||||
<table>
|
|
||||||
{{ dateform.as_table }}
|
|
||||||
</table>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
<p>
|
|
||||||
{% csrf_token %}
|
|
||||||
<input name='daterange' class="button green" type="submit" value="Submit">
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
{% if team %}
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/team-compare-select/team/{{ team.id }}/" method="post">
|
|
||||||
{% else %}
|
|
||||||
<form enctype="multipart/form-data" action="/rowers/team-compare-select/" method="post">
|
|
||||||
{% endif %}
|
|
||||||
<table>
|
|
||||||
{{ modalityform.as_table }}
|
|
||||||
</table>
|
|
||||||
</li>
|
|
||||||
<li>
|
|
||||||
{% csrf_token %}
|
|
||||||
<p>
|
|
||||||
<input name='modalityform' class="button green" type="submit" value="Submit">
|
|
||||||
</p>
|
|
||||||
</form>
|
|
||||||
</li>
|
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
{% if team %}
|
{% if team %}
|
||||||
<form id="searchform" action="/rowers/team-compare-select/team/{{ team.id }}/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}"
|
<form id="searchform" action=""
|
||||||
method="get" accept-charset="utf-8">
|
method="get" accept-charset="utf-8">
|
||||||
{% else %}
|
{% else %}
|
||||||
<form id="searchform" action="/rowers/team-compare-select/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}"
|
<form id="searchform" action="/rowers/team-compare-select/{{ startdate|date:"Y-m-d" }}/{{ enddate|date:"Y-m-d" }}"
|
||||||
@@ -142,19 +145,6 @@
|
|||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<p>Select two or more workouts on the left, set your plot settings below,
|
|
||||||
and press submit</p>
|
|
||||||
<p>
|
|
||||||
You can use the date and search forms above to search through all
|
|
||||||
workouts from this team.
|
|
||||||
</p>
|
|
||||||
<p>
|
|
||||||
TIP: Agree with your team members to put tags (e.g. '8x500m')
|
|
||||||
in the notes section of
|
|
||||||
your workouts. That makes it easy to search.
|
|
||||||
</p>
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -107,9 +107,6 @@ $('#id_workouttype').change();
|
|||||||
{{ workout.summary }}
|
{{ workout.summary }}
|
||||||
</pre>
|
</pre>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
|
||||||
<a href="/rowers/workout/{{ workout.id }}/recalcsummary">Update Summary</a>
|
|
||||||
</p>
|
|
||||||
</li>
|
</li>
|
||||||
{% if mapdiv %}
|
{% if mapdiv %}
|
||||||
<li class="grid_2">
|
<li class="grid_2">
|
||||||
|
|||||||
@@ -240,9 +240,9 @@ urlpatterns = [
|
|||||||
url(r'^workout/(?P<id>\d+)/edit$',views.workout_edit_view,
|
url(r'^workout/(?P<id>\d+)/edit$',views.workout_edit_view,
|
||||||
name='workout_edit_view'),
|
name='workout_edit_view'),
|
||||||
url(r'^workout/(?P<id>\d+)/map$',views.workout_map_view),
|
url(r'^workout/(?P<id>\d+)/map$',views.workout_map_view),
|
||||||
url(r'^workout/(?P<id>\d+)/setprivate$',views.workout_setprivate_view),
|
# url(r'^workout/(?P<id>\d+)/setprivate$',views.workout_setprivate_view),
|
||||||
url(r'^workout/(?P<id>\d+)/updatecp$',views.workout_update_cp_view),
|
url(r'^workout/(?P<id>\d+)/updatecp$',views.workout_update_cp_view),
|
||||||
url(r'^workout/(?P<id>\d+)/makepublic$',views.workout_makepublic_view),
|
# url(r'^workout/(?P<id>\d+)/makepublic$',views.workout_makepublic_view),
|
||||||
# url(r'^workout/(?P<id>\d+)/geeky$',views.workout_geeky_view),
|
# url(r'^workout/(?P<id>\d+)/geeky$',views.workout_geeky_view),
|
||||||
# url(r'^workout/(?P<id>\d+)/advanced$',views.workout_advanced_view),
|
# url(r'^workout/(?P<id>\d+)/advanced$',views.workout_advanced_view),
|
||||||
url(r'^workout/(?P<id>\d+)/instroke/(?P<metric>\w+.*)$',views.instroke_chart),
|
url(r'^workout/(?P<id>\d+)/instroke/(?P<metric>\w+.*)$',views.instroke_chart),
|
||||||
|
|||||||
217
rowers/views.py
217
rowers/views.py
@@ -5136,21 +5136,16 @@ def team_comparison_select(request,
|
|||||||
modalities = [m[0] for m in types.workouttypes]
|
modalities = [m[0] for m in types.workouttypes]
|
||||||
modality = 'all'
|
modality = 'all'
|
||||||
|
|
||||||
if request.method == 'POST' and 'daterange' in request.POST:
|
if request.method == 'POST':
|
||||||
dateform = DateRangeForm(request.POST)
|
dateform = DateRangeForm(request.POST)
|
||||||
if dateform.is_valid():
|
if dateform.is_valid():
|
||||||
startdate = dateform.cleaned_data['startdate']
|
startdate = dateform.cleaned_data['startdate']
|
||||||
enddate = dateform.cleaned_data['enddate']
|
enddate = dateform.cleaned_data['enddate']
|
||||||
startdatestring = startdate.strftime('%Y-%m-%d')
|
startdatestring = startdate.strftime('%Y-%m-%d')
|
||||||
enddatestring = enddate.strftime('%Y-%m-%d')
|
enddatestring = enddate.strftime('%Y-%m-%d')
|
||||||
else:
|
request.session['startdate'] = startdatestring
|
||||||
dateform = DateRangeForm(initial={
|
request.session['enddate'] = enddatestring
|
||||||
'startdate':startdate,
|
|
||||||
'enddate':enddate,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
if request.method == 'POST' and 'modality' in request.POST:
|
|
||||||
modalityform = TrendFlexModalForm(request.POST)
|
modalityform = TrendFlexModalForm(request.POST)
|
||||||
if modalityform.is_valid():
|
if modalityform.is_valid():
|
||||||
modality = modalityform.cleaned_data['modality']
|
modality = modalityform.cleaned_data['modality']
|
||||||
@@ -5171,6 +5166,19 @@ def team_comparison_select(request,
|
|||||||
|
|
||||||
request.session['modalities'] = modalities
|
request.session['modalities'] = modalities
|
||||||
request.session['waterboattype'] = waterboattype
|
request.session['waterboattype'] = waterboattype
|
||||||
|
else:
|
||||||
|
dateform = DateRangeForm(initial={
|
||||||
|
'startdate':startdate,
|
||||||
|
'enddate':enddate,
|
||||||
|
})
|
||||||
|
modalityform = TrendFlexModalForm(initial={
|
||||||
|
'modality':modality,
|
||||||
|
'waterboattype':waterboattype,
|
||||||
|
'rankingonly':rankingonly,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
negtypes = []
|
negtypes = []
|
||||||
for b in types.boattypes:
|
for b in types.boattypes:
|
||||||
@@ -5241,16 +5249,23 @@ def team_comparison_select(request,
|
|||||||
theid = 0
|
theid = 0
|
||||||
|
|
||||||
chartform = ChartParamChoiceForm(initial={'teamid':0})
|
chartform = ChartParamChoiceForm(initial={'teamid':0})
|
||||||
modalityform = TrendFlexModalForm(initial={
|
|
||||||
'modality':modality,
|
|
||||||
'waterboattype':waterboattype,
|
|
||||||
'rankingonly':rankingonly,
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
messages.info(request,successmessage)
|
messages.info(request,successmessage)
|
||||||
messages.error(request,message)
|
messages.error(request,message)
|
||||||
|
|
||||||
|
r = getrower(request.user)
|
||||||
|
breadcrumbs = [
|
||||||
|
{
|
||||||
|
'url':'/rowers/list-workouts',
|
||||||
|
'name':'Workouts'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse(team_comparison_select,kwargs={'teamid':teamid}),
|
||||||
|
'name': 'Compare Select'
|
||||||
|
},
|
||||||
|
|
||||||
|
]
|
||||||
|
|
||||||
return render(request, 'team_compare_select.html',
|
return render(request, 'team_compare_select.html',
|
||||||
{'workouts': workouts,
|
{'workouts': workouts,
|
||||||
'dateform':dateform,
|
'dateform':dateform,
|
||||||
@@ -5258,6 +5273,8 @@ def team_comparison_select(request,
|
|||||||
'enddate':enddate,
|
'enddate':enddate,
|
||||||
'team':theteam,
|
'team':theteam,
|
||||||
'form':form,
|
'form':form,
|
||||||
|
'rower':r,
|
||||||
|
'breadcrumbs':breadcrumbs,
|
||||||
'active':'nav-workouts',
|
'active':'nav-workouts',
|
||||||
'chartform':chartform,
|
'chartform':chartform,
|
||||||
'modalityform':modalityform,
|
'modalityform':modalityform,
|
||||||
@@ -5303,9 +5320,27 @@ def multi_compare_view(request):
|
|||||||
if errormessage != '':
|
if errormessage != '':
|
||||||
messages.error(request,errormessage)
|
messages.error(request,errormessage)
|
||||||
|
|
||||||
|
r = getrower(request.user)
|
||||||
|
breadcrumbs = [
|
||||||
|
{
|
||||||
|
'url':'/rowers/list-workouts',
|
||||||
|
'name':'Workouts'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse(team_comparison_select,kwargs={'teamid':teamid}),
|
||||||
|
'name': 'Compare Select'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse(multi_compare_view),
|
||||||
|
'name': 'Comparison Chart'
|
||||||
|
}
|
||||||
|
]
|
||||||
return render(request,'multicompare.html',
|
return render(request,'multicompare.html',
|
||||||
{'interactiveplot':script,
|
{'interactiveplot':script,
|
||||||
'the_div':div,
|
'the_div':div,
|
||||||
|
'breadcrumbs':breadcrumbs,
|
||||||
|
'rower':r,
|
||||||
|
'active':'nav-workouts',
|
||||||
'promember':promember,
|
'promember':promember,
|
||||||
'teamid':teamid,
|
'teamid':teamid,
|
||||||
'chartform':chartform,
|
'chartform':chartform,
|
||||||
@@ -5335,9 +5370,29 @@ def multi_compare_view(request):
|
|||||||
script = res[0]
|
script = res[0]
|
||||||
div = res[1]
|
div = res[1]
|
||||||
|
|
||||||
|
r = getrower(request.user)
|
||||||
|
breadcrumbs = [
|
||||||
|
{
|
||||||
|
'url':'/rowers/list-workouts',
|
||||||
|
'name':'Workouts'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse(team_comparison_select,kwargs={'teamid':teamid}),
|
||||||
|
'name': 'Compare Select'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
'url':reverse(multi_compare_view),
|
||||||
|
'name': 'Comparison Chart'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
return render(request,'multicompare.html',
|
return render(request,'multicompare.html',
|
||||||
{'interactiveplot':script,
|
{'interactiveplot':script,
|
||||||
'the_div':div,
|
'the_div':div,
|
||||||
|
'breadcrumbs':breadcrumbs,
|
||||||
|
'rower':r,
|
||||||
|
'active':'nav-workouts',
|
||||||
'promember':promember,
|
'promember':promember,
|
||||||
'teamid':teamid,
|
'teamid':teamid,
|
||||||
'chartform':chartform,
|
'chartform':chartform,
|
||||||
@@ -6475,74 +6530,76 @@ def workout_comparison_list(request,id=0,message='',successmessage='',
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
r = getrower(request.user)
|
r = getrower(request.user)
|
||||||
u = User.objects.get(id=r.user.id)
|
|
||||||
if request.method == 'POST':
|
|
||||||
dateform = DateRangeForm(request.POST)
|
|
||||||
if dateform.is_valid():
|
|
||||||
startdate = dateform.cleaned_data['startdate']
|
|
||||||
enddate = dateform.cleaned_data['enddate']
|
|
||||||
else:
|
|
||||||
dateform = DateRangeForm(initial={
|
|
||||||
'startdate':startdate,
|
|
||||||
'enddate':enddate,
|
|
||||||
})
|
|
||||||
|
|
||||||
if startdatestring:
|
|
||||||
startdate = iso8601.parse_date(startdatestring)
|
|
||||||
if enddatestring:
|
|
||||||
enddate = iso8601.parse_date(enddatestring)
|
|
||||||
|
|
||||||
startdate = datetime.datetime.combine(startdate,datetime.time())
|
|
||||||
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
|
|
||||||
#enddate = enddate+datetime.timedelta(days=1)
|
|
||||||
|
|
||||||
if enddate < startdate:
|
|
||||||
s = enddate
|
|
||||||
enddate = startdate
|
|
||||||
startdate = s
|
|
||||||
|
|
||||||
workouts = Workout.objects.filter(user=r,
|
|
||||||
startdatetime__gte=startdate,
|
|
||||||
startdatetime__lte=enddate).order_by("-date", "-starttime").exclude(id=id)
|
|
||||||
|
|
||||||
query = request.GET.get('q')
|
|
||||||
if query:
|
|
||||||
query_list = query.split()
|
|
||||||
workouts = workouts.filter(
|
|
||||||
reduce(operator.and_,
|
|
||||||
(Q(name__icontains=q) for q in query_list)) |
|
|
||||||
reduce(operator.and_,
|
|
||||||
(Q(notes__icontains=q) for q in query_list))
|
|
||||||
)
|
|
||||||
|
|
||||||
paginator = Paginator(workouts,15) # show 25 workouts per page
|
|
||||||
page = request.GET.get('page')
|
|
||||||
|
|
||||||
try:
|
|
||||||
workouts = paginator.page(page)
|
|
||||||
except PageNotAnInteger:
|
|
||||||
workouts = paginator.page(1)
|
|
||||||
except EmptyPage:
|
|
||||||
workouts = paginator.page(paginator.num_pages)
|
|
||||||
|
|
||||||
row = get_workout(id)
|
|
||||||
|
|
||||||
messages.error(request,message)
|
|
||||||
messages.info(request,successmessage)
|
|
||||||
|
|
||||||
return render(request, 'comparison_list.html',
|
|
||||||
{'id':int(id),
|
|
||||||
'workout':row,
|
|
||||||
'workouts': workouts,
|
|
||||||
'last_name':u.last_name,
|
|
||||||
'first_name':u.first_name,
|
|
||||||
'dateform':dateform,
|
|
||||||
'startdate':startdate,
|
|
||||||
'enddate':enddate,
|
|
||||||
'teams':get_my_teams(request.user),
|
|
||||||
})
|
|
||||||
except Rower.DoesNotExist:
|
except Rower.DoesNotExist:
|
||||||
raise Http404("User has no rower instance")
|
raise Http404("User has no rower instance")
|
||||||
|
u = User.objects.get(id=r.user.id)
|
||||||
|
|
||||||
|
if request.method == 'POST':
|
||||||
|
dateform = DateRangeForm(request.POST)
|
||||||
|
if dateform.is_valid():
|
||||||
|
startdate = dateform.cleaned_data['startdate']
|
||||||
|
enddate = dateform.cleaned_data['enddate']
|
||||||
|
else:
|
||||||
|
dateform = DateRangeForm(initial={
|
||||||
|
'startdate':startdate,
|
||||||
|
'enddate':enddate,
|
||||||
|
})
|
||||||
|
|
||||||
|
if startdatestring:
|
||||||
|
startdate = iso8601.parse_date(startdatestring)
|
||||||
|
if enddatestring:
|
||||||
|
enddate = iso8601.parse_date(enddatestring)
|
||||||
|
|
||||||
|
startdate = datetime.datetime.combine(startdate,datetime.time())
|
||||||
|
enddate = datetime.datetime.combine(enddate,datetime.time(23,59,59))
|
||||||
|
#enddate = enddate+datetime.timedelta(days=1)
|
||||||
|
|
||||||
|
if enddate < startdate:
|
||||||
|
s = enddate
|
||||||
|
enddate = startdate
|
||||||
|
startdate = s
|
||||||
|
|
||||||
|
workouts = Workout.objects.filter(user=r,
|
||||||
|
startdatetime__gte=startdate,
|
||||||
|
startdatetime__lte=enddate).order_by("-date", "-starttime").exclude(id=id)
|
||||||
|
|
||||||
|
query = request.GET.get('q')
|
||||||
|
if query:
|
||||||
|
query_list = query.split()
|
||||||
|
workouts = workouts.filter(
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(name__icontains=q) for q in query_list)) |
|
||||||
|
reduce(operator.and_,
|
||||||
|
(Q(notes__icontains=q) for q in query_list))
|
||||||
|
)
|
||||||
|
|
||||||
|
paginator = Paginator(workouts,15) # show 25 workouts per page
|
||||||
|
page = request.GET.get('page')
|
||||||
|
|
||||||
|
try:
|
||||||
|
workouts = paginator.page(page)
|
||||||
|
except PageNotAnInteger:
|
||||||
|
workouts = paginator.page(1)
|
||||||
|
except EmptyPage:
|
||||||
|
workouts = paginator.page(paginator.num_pages)
|
||||||
|
|
||||||
|
row = get_workout(id)
|
||||||
|
|
||||||
|
messages.error(request,message)
|
||||||
|
messages.info(request,successmessage)
|
||||||
|
|
||||||
|
return render(request, 'comparison_list.html',
|
||||||
|
{'id':int(id),
|
||||||
|
'workout':row,
|
||||||
|
'workouts': workouts,
|
||||||
|
'last_name':u.last_name,
|
||||||
|
'first_name':u.first_name,
|
||||||
|
'dateform':dateform,
|
||||||
|
'startdate':startdate,
|
||||||
|
'enddate':enddate,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
# List of workouts to compare a selected workout to
|
# List of workouts to compare a selected workout to
|
||||||
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)
|
||||||
|
|||||||
Reference in New Issue
Block a user