Private
Public Access
1
0

form in place, not working yet

This commit is contained in:
Sander Roosendaal
2018-06-11 15:26:14 +02:00
parent a6a564559c
commit 634e191d65
3 changed files with 231 additions and 171 deletions

View File

@@ -481,6 +481,20 @@ class MyTimeField(forms.TimeField):
super(MyTimeField, self).__init__(*args, **kwargs) super(MyTimeField, self).__init__(*args, **kwargs)
supports_microseconds = True supports_microseconds = True
# Form used to automatically define intervals by pace or power
class PowerIntervalUpdateForm(forms.Form):
selectorchoices = (
('power','Power'),
('pace','Pace')
)
pace = forms.DurationField(label='Pace',required=False)
power = forms.IntegerField(label='Power',required=False)
selector = forms.ChoiceField(choices=selectorchoices,
required=True,
initial='power',
label='Use')
# Form used to update interval stats # Form used to update interval stats
class IntervalUpdateForm(forms.Form): class IntervalUpdateForm(forms.Form):

View File

@@ -99,6 +99,26 @@
<input class="button green" type="submit" value="Update"> <input class="button green" type="submit" value="Update">
</div> </div>
</form> </form>
<h1>Intervals by Power/Pace</h1>
<p>With this form, you can specify a power or pace level. Everything faster/harder than the
specified pace/power will become a work interval. Everything slower will become a rest
interval.
</p>
<form ecntype="multipart/form-data" method="post">
<table>
{{ powerupdateform.as_table }}
</table>
{% csrf_token %}
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
<input class="button green" type="submit" value="Submit">
</div>
</form>
</div> </div>
<div id="advancedplots" class="grid_6 omega"> <div id="advancedplots" class="grid_6 omega">
@@ -203,5 +223,5 @@
</div> </div>
</form> </form>
</div> </div>
</div>
{% endblock %} {% endblock %}

View File

@@ -39,7 +39,7 @@ from rowers.forms import (
LandingPageForm,PlannedSessionSelectForm,WorkoutSessionSelectForm, LandingPageForm,PlannedSessionSelectForm,WorkoutSessionSelectForm,
PlannedSessionTeamForm,PlannedSessionTeamMemberForm, PlannedSessionTeamForm,PlannedSessionTeamMemberForm,
VirtualRaceSelectForm,WorkoutRaceSelectForm,CourseSelectForm, VirtualRaceSelectForm,WorkoutRaceSelectForm,CourseSelectForm,
RaceResultFilterForm, RaceResultFilterForm,PowerIntervalUpdateForm
) )
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
from django.core.exceptions import PermissionDenied from django.core.exceptions import PermissionDenied
@@ -11303,6 +11303,31 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
form = SummaryStringForm(initial=data) form = SummaryStringForm(initial=data)
savebutton = 'savestringform' savebutton = 'savestringform'
# we are saving the results obtained from the power update form
elif request.method == 'POST' and 'selector' in request.POST:
powerupdateform = PowerIntervalUpdateForm(request.POST)
if powerupdateform.is_valid():
cd = powerupdateform.cleaned_data
powerorpace = cd['selector']
power = cd['power']
pace = cd['pace']
if powerorpace == 'power':
try:
rowdata.updateinterval_power(power)
except:
messages.error(request,'Error updating power')
elif powerorpace == 'pace':
try:
rowdata.updateinterval_pace(pace)
except:
messages.error(request,'Error updating pace')
intervalstats = rowdata.allstats()
itime,idist,itype = rowdata.intervalstats_values()
nrintervals = len(idist)
savebutton = 'savestringform'
# we are saving the results obtained from the detailed form # we are saving the results obtained from the detailed form
elif request.method == 'POST' and "savedetailform" in request.POST: elif request.method == 'POST' and "savedetailform" in request.POST:
savebutton = 'savedetailform' savebutton = 'savedetailform'
@@ -11410,13 +11435,14 @@ def workout_summary_edit_view(request,id,message="",successmessage=""
detailform = IntervalUpdateForm(aantal=nrintervals,initial=initial) detailform = IntervalUpdateForm(aantal=nrintervals,initial=initial)
powerupdateform = PowerIntervalUpdateForm()
# render page # render page
return render(request, 'summary_edit.html', return render(request, 'summary_edit.html',
{'form':form, {'form':form,
'detailform':detailform, 'detailform':detailform,
'powerupdateform':powerupdateform,
'workout':row, 'workout':row,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'intervalstats':intervalstats, 'intervalstats':intervalstats,