initial nonfunct fusion form and view
This commit is contained in:
@@ -260,7 +260,7 @@ class WorkoutMultipleCompareForm(forms.Form):
|
||||
from rowers.interactiveplots import axlabels
|
||||
|
||||
axlabels.pop('None')
|
||||
axlabels = list(sorted(axlabels.items(), key = lambda x:x[1]))
|
||||
parchoices = list(sorted(axlabels.items(), key = lambda x:x[1]))
|
||||
|
||||
|
||||
class ChartParamChoiceForm(forms.Form):
|
||||
@@ -268,7 +268,15 @@ class ChartParamChoiceForm(forms.Form):
|
||||
('line','Line Plot'),
|
||||
('scatter','Scatter Plot'),
|
||||
)
|
||||
xparam = forms.ChoiceField(choices=axlabels,initial='distance')
|
||||
yparam = forms.ChoiceField(choices=axlabels,initial='hr')
|
||||
xparam = forms.ChoiceField(choices=parchoices,initial='distance')
|
||||
yparam = forms.ChoiceField(choices=parchoices,initial='hr')
|
||||
plottype = forms.ChoiceField(choices=plotchoices,initial='scatter')
|
||||
teamid = forms.IntegerField(widget=forms.HiddenInput())
|
||||
|
||||
axlabels.pop('time')
|
||||
metricchoices = list(sorted(axlabels.items(), key = lambda x:x[1]))
|
||||
|
||||
class FusionMetricChoiceForm(forms.Form):
|
||||
columns = forms.MultipleChoiceField(choices=metricchoices,
|
||||
initial=[],
|
||||
widget=forms.CheckboxSelectMultiple())
|
||||
|
||||
44
rowers/templates/fusion.html
Normal file
44
rowers/templates/fusion.html
Normal file
@@ -0,0 +1,44 @@
|
||||
{% extends "base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}Workouts{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
<div class="grid_12 alpha">
|
||||
<h3>Fusion Editor</h3>
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div class="grid_6 alpha">
|
||||
<p>
|
||||
Adding sensor data from workout {{ workout2.id }} into workout {{ workout1.id2 }}.
|
||||
This will create a new workout. After you submit the form, you will be
|
||||
taken to the newly created workout. If you are happy with the result, you
|
||||
can delete the two original workouts manually.
|
||||
</p>
|
||||
<p>
|
||||
Workout 1: {{ workout1.name }}
|
||||
</p>
|
||||
<p>
|
||||
Workout 2: {{ workout2.name }}
|
||||
</p>
|
||||
<p>On the right hand side, please select the columns from workout 2 that
|
||||
you want to replace the equivalent columns in workout 1. </p>
|
||||
</div>
|
||||
<div class="grid_4">
|
||||
|
||||
<form enctype="multipart/form-data" action="" method="post">
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
</div>
|
||||
<div class="grid_2 omega">
|
||||
<input name='fusion' class="button green" type="submit" value="Submit"> </form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -189,6 +189,7 @@ urlpatterns = [
|
||||
url(r'^workout/(\d+)/interactiveplot$',views.workout_biginteractive_view),
|
||||
url(r'^workout/(\d+)/view$',views.workout_view),
|
||||
url(r'^workout/(\d+)$',views.workout_view),
|
||||
url(r'^workout/fusion/(?P<id1>\d+)/(?P<id2>\d+)$',views.workout_fusion_view),
|
||||
url(r'^physics$',TemplateView.as_view(template_name='physics.html'),name='physics'),
|
||||
url(r'^workout/(\d+)/$',views.workout_view),
|
||||
url(r'^workout/(\d+)/addtimeplot$',views.workout_add_timeplot_view),
|
||||
|
||||
@@ -26,7 +26,8 @@ from rowers.forms import (
|
||||
StatsOptionsForm,PredictedPieceForm,DateRangeForm,DeltaDaysForm,
|
||||
EmailForm, RegistrationForm, RegistrationFormTermsOfService,
|
||||
RegistrationFormUniqueEmail,CNsummaryForm,UpdateWindForm,
|
||||
UpdateStreamForm,WorkoutMultipleCompareForm,ChartParamChoiceForm
|
||||
UpdateStreamForm,WorkoutMultipleCompareForm,ChartParamChoiceForm,
|
||||
FusionMetricChoiceForm,
|
||||
)
|
||||
from rowers.models import Workout, User, Rower, WorkoutForm,FavoriteChart
|
||||
from rowers.models import (
|
||||
@@ -2617,7 +2618,7 @@ def workout_wind_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
|
||||
# get data
|
||||
f1 = row.csvfilename
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
|
||||
@@ -2732,7 +2733,7 @@ def workout_stream_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
|
||||
# create interactive plot
|
||||
f1 = row.csvfilename
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
|
||||
@@ -2892,7 +2893,7 @@ def workout_geeky_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
|
||||
# create interactive plot
|
||||
f1 = row.csvfilename
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
|
||||
@@ -3209,7 +3210,7 @@ def workout_advanced_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
|
||||
# create interactive plot
|
||||
f1 = row.csvfilename
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
|
||||
@@ -3527,7 +3528,7 @@ def workout_biginteractive_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
|
||||
# create interactive plot
|
||||
f1 = row.csvfilename
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
# r = Rower.objects.get(user=u)
|
||||
|
||||
@@ -3568,7 +3569,7 @@ def workout_otwpowerplot_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
|
||||
# create interactive plot
|
||||
f1 = row.csvfilename
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
# r = Rower.objects.get(user=u)
|
||||
|
||||
@@ -3766,6 +3767,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
|
||||
try:
|
||||
# check if valid ID exists (workout exists)
|
||||
row = Workout.objects.get(id=id)
|
||||
form = WorkoutForm(instance=row)
|
||||
except Workout.DoesNotExist:
|
||||
raise Http404("Workout doesn't exist")
|
||||
@@ -3815,12 +3817,11 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
r.rowdatetime = startdatetime
|
||||
r.write_csv(row.csvfilename,gzip=True)
|
||||
dataprep.update_strokedata(id,r.df)
|
||||
successmessage = "Changes saved"
|
||||
successmessage = "Changes saved"
|
||||
url = reverse(workout_edit_view,
|
||||
kwargs = {
|
||||
'id':str(row.id),
|
||||
'successmessage':str(successmessage),
|
||||
'successmessage':str(successmessage),
|
||||
})
|
||||
response = HttpResponseRedirect(url)
|
||||
else:
|
||||
@@ -3845,7 +3846,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
|
||||
raise Http404("You are not allowed to edit this workout")
|
||||
|
||||
# create interactive plot
|
||||
f1 = row.csvfilename
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
rowdata = rdata(f1)
|
||||
@@ -3914,7 +3915,7 @@ def workout_add_otw_powerplot_view(request,id):
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
u = w.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
powerperc = 100*np.array([r.pw_ut2,
|
||||
@@ -3971,7 +3972,7 @@ def workout_add_piechart_view(request,id):
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
u = w.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
|
||||
@@ -4029,7 +4030,7 @@ def workout_add_power_piechart_view(request,id):
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
u = w.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
|
||||
@@ -4085,7 +4086,7 @@ def workout_add_timeplot_view(request,id):
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
u = w.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
powerperc = 100*np.array([r.pw_ut2,
|
||||
@@ -4142,7 +4143,7 @@ def workout_add_distanceplot_view(request,id):
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
u = w.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
powerperc = 100*np.array([r.pw_ut2,
|
||||
@@ -4197,7 +4198,7 @@ def workout_add_distanceplot2_view(request,id):
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
u = w.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
powerperc = 100*np.array([r.pw_ut2,
|
||||
@@ -4254,7 +4255,7 @@ def workout_add_timeplot2_view(request,id):
|
||||
f1 = w.csvfilename[6:-4]
|
||||
timestr = strftime("%Y%m%d-%H%M%S")
|
||||
imagename = f1+timestr+'.png'
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
fullpathimagename = 'static/plots/'+imagename
|
||||
u = w.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
powerperc = 100*np.array([r.pw_ut2,
|
||||
@@ -4944,7 +4945,7 @@ def workout_summary_restore_view(request,id,message="",successmessage=""):
|
||||
|
||||
s = ""
|
||||
# still here - this is a workout we may edit
|
||||
f1 = row.csvfilename
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
powerperc = 100*np.array([r.pw_ut2,
|
||||
@@ -4984,6 +4985,26 @@ def workout_summary_restore_view(request,id,message="",successmessage=""):
|
||||
|
||||
)
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
# Fuse two workouts
|
||||
@login_required()
|
||||
def workout_fusion_view(request,id1=0,id2=1):
|
||||
try:
|
||||
w1 = Workout.objects.get(id=id1)
|
||||
w2 = Workout.objects.get(id=id2)
|
||||
if (checkworkoutuser(request.user,w1)==False) or \
|
||||
(checkworkoutuser(request.user,w2)==False):
|
||||
raise PermissionDenied("You are not allowed to use these workouts")
|
||||
except Workout.DoesNotExist:
|
||||
raise Http404("One of the workouts doesn't exist")
|
||||
|
||||
form = FusionMetricChoiceForm()
|
||||
|
||||
return render(request, 'fusion.html',
|
||||
{'form':form,
|
||||
'workout1':w1,
|
||||
'workout2':w2,
|
||||
})
|
||||
|
||||
|
||||
# Edit the splits/summary
|
||||
@@ -4999,7 +5020,7 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
|
||||
|
||||
s = ""
|
||||
# still here - this is a workout we may edit
|
||||
f1 = row.csvfilename
|
||||
f1 = row.csvfilename
|
||||
u = row.user.user
|
||||
r = Rower.objects.get(user=u)
|
||||
powerperc = 100*np.array([r.pw_ut2,
|
||||
|
||||
Reference in New Issue
Block a user