removing older compare functions
This commit is contained in:
@@ -1291,6 +1291,15 @@ class AnalysisChoiceForm(forms.Form):
|
||||
label='Include Rest Strokes')
|
||||
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(AnalysisChoiceForm, self).__init__(*args, **kwargs)
|
||||
|
||||
if 'initial' in kwargs and kwargs['initial']['function'] == 'compare':
|
||||
self.fields['xaxis'].initial = 'time'
|
||||
self.fields['yaxis1'].initial = 'hr'
|
||||
self.fields['plottype'].initial = 'line'
|
||||
|
||||
|
||||
|
||||
class BoxPlotChoiceForm(forms.Form):
|
||||
yparam = forms.ChoiceField(choices=parchoices,initial='spm',
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
</a>
|
||||
</li>
|
||||
<li id="compare">
|
||||
<a href="/rowers/team-compare-select/workout/{{ workout.id|encode }}/">
|
||||
<a href="/rowers/user-analysis-select/compare/workout/{{ workout.id|encode }}/">
|
||||
<i class="fas fa-balance-scale fa-fw"></i> Compare
|
||||
</a>
|
||||
</li>
|
||||
|
||||
@@ -36,7 +36,7 @@ from django.core.files.uploadedfile import SimpleUploadedFile
|
||||
from io import StringIO
|
||||
|
||||
from django.test.client import RequestFactory
|
||||
from rowers.views import c2_open, multi_compare_view
|
||||
from rowers.views import c2_open
|
||||
|
||||
|
||||
from rowers.forms import (
|
||||
|
||||
@@ -312,17 +312,6 @@ urlpatterns = [
|
||||
re_path(r'^standards/upload/(?P<id>\d+)/$',views.standards_upload_view,name='standards_upload_view'),
|
||||
re_path(r'^workout/addmanual/(?P<raceid>\d+)/$',views.addmanual_view,name='addmanual_view'),
|
||||
re_path(r'^workout/addmanual/$',views.addmanual_view,name='addmanual_view'),
|
||||
re_path(r'^team-compare-select/workout/(?P<id>\d+)/team/(?P<teamid>\d+)/user/(?P<userid>\d+)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/workout/(?P<id>\b[0-9A-Fa-f]+\b)/team/(?P<teamid>\d+)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/workout/(?P<id>\b[0-9A-Fa-f]+\b)/team/(?P<teamid>\d+)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/workout/(?P<id>\b[0-9A-Fa-f]+\b)/team/(?P<teamid>\d+)/user/(?P<userid>\d+)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/(?P<startdatestring>\d+-\d+-\d+)/(?P<enddatestring>\d+-\d+-\d+)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/workout/(?P<id>\b[0-9A-Fa-f]+\b)/user/(?P<userid>\d+)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/team/(?P<teamid>\d+)/user/(?P<userid>\d+)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/workout/(?P<id>\b[0-9A-Fa-f]+\b)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/team/(?P<teamid>\d+)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/user/(?P<userid>\d+)/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^team-compare-select/$',views.team_comparison_select,name='team_comparison_select'),
|
||||
re_path(r'^workouts-join/$',views.workouts_join_view,name='workouts_join_view'),
|
||||
re_path(r'^workouts-join/user/(?P<userid>\d+)$',views.workouts_join_view,name='workouts_join_view'),
|
||||
re_path(r'^workouts-join-select/$',views.workouts_join_select,name='workouts_join_select'),
|
||||
@@ -522,10 +511,6 @@ urlpatterns = [
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/recalcsummary/$',views.workout_recalcsummary_view,name='workout_recalcsummary_view'),
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/sporttracksuploadw/$',views.workout_sporttracks_upload_view,name='workout_sporttracks_upload_view'),
|
||||
re_path(r'^workout/(?P<id>\b[0-9A-Fa-f]+\b)/tpuploadw/$',views.workout_tp_upload_view,name='workout_tp_upload_view'),
|
||||
re_path(r'^multi-compare/workout/(?P<id>\b[0-9A-Fa-f]+\b)/user/(?P<userid>\d+)/$',views.multi_compare_view,
|
||||
name='multi_compare_view'),
|
||||
re_path(r'^multi-compare/workout/(?P<id>\b[0-9A-Fa-f]+\b)/$',views.multi_compare_view,name='multi_compare_view'),
|
||||
re_path(r'^multi-compare/$',views.multi_compare_view,name='multi_compare_view'),
|
||||
re_path(r'^alerts/user/(?P<userid>\d+)/$',views.alerts_view,name='alerts_view'),
|
||||
re_path(r'^alerts/$',views.alerts_view,name='alerts_view'),
|
||||
re_path(r'^alerts/(?P<pk>\d+)/delete/$',views.AlertDelete.as_view(),name='alert_delete_view'),
|
||||
|
||||
@@ -2055,155 +2055,6 @@ def plannedsession_compare_view(request,id=0,userid=0):
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# Team comparison
|
||||
@login_required()
|
||||
def multi_compare_view(request,id=0,userid=0):
|
||||
promember=0
|
||||
if not request.user.is_anonymous:
|
||||
r = getrower(request.user)
|
||||
result = request.user.is_authenticated and ispromember(request.user)
|
||||
if result:
|
||||
promember=1
|
||||
|
||||
if request.method == 'POST' and 'workouts' in request.POST:
|
||||
form = WorkoutMultipleCompareForm(request.POST)
|
||||
chartform = ChartParamChoiceForm(request.POST)
|
||||
if form.is_valid() and chartform.is_valid():
|
||||
cd = form.cleaned_data
|
||||
workouts = cd['workouts']
|
||||
xparam = chartform.cleaned_data['xparam']
|
||||
yparam = chartform.cleaned_data['yparam']
|
||||
plottype = chartform.cleaned_data['plottype']
|
||||
teamid = chartform.cleaned_data['teamid']
|
||||
ids = [int(w.id) for w in workouts]
|
||||
request.session['ids'] = ids
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__str__() for w in workouts
|
||||
}
|
||||
|
||||
else: # pragma: no cover
|
||||
return HttpResponse("Form is not valid")
|
||||
elif request.method == 'POST' and 'ids' in request.session:
|
||||
chartform = ChartParamChoiceForm(request.POST)
|
||||
if chartform.is_valid():
|
||||
xparam = chartform.cleaned_data['xparam']
|
||||
yparam = chartform.cleaned_data['yparam']
|
||||
plottype = chartform.cleaned_data['plottype']
|
||||
teamid = chartform.cleaned_data['teamid']
|
||||
ids = request.session['ids']
|
||||
request.session['ids'] = ids
|
||||
workouts = []
|
||||
for id in ids:
|
||||
try:
|
||||
workouts.append(Workout.objects.get(id=id))
|
||||
except Workout.DoesNotExist: # pragma: no cover
|
||||
pass
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__str__() for w in workouts
|
||||
}
|
||||
elif 'ids' in request.session and 'plottype' in request.session:
|
||||
xparam = request.session['xparam']
|
||||
yparam = request.session['yparam']
|
||||
plottype = request.session['plottype']
|
||||
teamid = 0
|
||||
ids = request.session['ids']
|
||||
workouts = []
|
||||
for id in ids:
|
||||
try:
|
||||
workouts.append(Workout.objects.get(id=id))
|
||||
except Workout.DoesNotExist: # pragma: no cover
|
||||
pass
|
||||
|
||||
labeldict = {
|
||||
int(w.id): w.__str__() for w in workouts
|
||||
}
|
||||
chartform = ChartParamChoiceForm(
|
||||
initial = {
|
||||
'xparam':xparam,
|
||||
'yparam':yparam,
|
||||
'plottype':plottype,
|
||||
'teamid':teamid
|
||||
}
|
||||
)
|
||||
|
||||
else:
|
||||
url = reverse('team_comparison_select',
|
||||
kwargs={
|
||||
'id':id,
|
||||
'teamid':0})
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
|
||||
res = interactive_multiple_compare_chart(ids,xparam,yparam,
|
||||
promember=promember,
|
||||
plottype=plottype,
|
||||
labeldict=labeldict)
|
||||
script = res[0]
|
||||
div = res[1]
|
||||
errormessage = res[3]
|
||||
if errormessage != '': # pragma: no cover
|
||||
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'
|
||||
}
|
||||
]
|
||||
|
||||
if 'ps' in request.session: # pragma: no cover
|
||||
ps = PlannedSession.objects.get(id=int(request.session['ps']))
|
||||
breadcrumbs = [
|
||||
{
|
||||
'url': reverse('plannedsessions_view',
|
||||
kwargs={'userid':userid}),
|
||||
'name': 'Sessions'
|
||||
},
|
||||
{
|
||||
'url':reverse('plannedsession_view',
|
||||
kwargs={
|
||||
'userid':userid,
|
||||
'id':ps.id,
|
||||
}
|
||||
),
|
||||
'name': ps.id
|
||||
},
|
||||
{
|
||||
'url':reverse('plannedsession_compare_view',
|
||||
kwargs={
|
||||
'userid':userid,
|
||||
'id':ps.id,
|
||||
}
|
||||
),
|
||||
'name': 'Compare'
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
return render(request,'multicompare.html',
|
||||
{'interactiveplot':script,
|
||||
'the_div':div,
|
||||
'breadcrumbs':breadcrumbs,
|
||||
'rower':r,
|
||||
'active':'nav-workouts',
|
||||
'promember':promember,
|
||||
'teamid':teamid,
|
||||
'chartform':chartform,
|
||||
'teams':get_my_teams(request.user),
|
||||
})
|
||||
|
||||
|
||||
# List Workouts
|
||||
@login_required()
|
||||
|
||||
Reference in New Issue
Block a user