Private
Public Access
1
0

adding user setting for CP duration range - default is 42 days

This commit is contained in:
Sander Roosendaal
2020-10-13 22:03:18 +02:00
parent 211bf1661c
commit c067a33372
5 changed files with 43 additions and 6 deletions

View File

@@ -756,6 +756,13 @@ class Rower(models.Model):
('y','y'),
)
cppresets = (
(42,'6 weeks'),
(91,'13 weeks'),
(183,'26 weeks'),
(365,'a year')
)
user = models.OneToOneField(User,on_delete=models.CASCADE)
#billing details
@@ -837,7 +844,8 @@ class Rower(models.Model):
ep3 = models.FloatField(default=1.0,verbose_name="erg CP p4")
ecpratio = models.FloatField(default=1.0,verbose_name="erg CP fit ratio")
cprange = models.IntegerField(default=42,verbose_name="Range for calculation breakthrough workouts and fitness (CP)",
choices=cppresets)
otwslack = models.IntegerField(default=0,verbose_name="OTW Power slack")
@@ -3538,6 +3546,11 @@ class RowerPowerForm(ModelForm):
model = Rower
fields = ['hrftp','ftp','otwslack']
class RowerCPForm(ModelForm):
class Meta:
model = Rower
fields = ['cprange']
# Form to set rower's Power zones, including test routines
# to enable consistency
class RowerPowerZonesForm(ModelForm):

View File

@@ -4,7 +4,7 @@
<ul class="cd-accordion-menu animated">
<li id="manage-prefs">
<a href="/rowers/me/preferences/">
<i class="fas fa-cog fa-fw"></i>&nbsp;Zones
<i class="fas fa-cog fa-fw"></i>&nbsp;Zones & Fitness
</a>
</li>
<li id="manage-impex">

View File

@@ -19,7 +19,7 @@
Please correct the error{{ form.errors|pluralize }} below.
</p>
{% endif %}
<form enctype="multipart/form-data" action="" method="post">
<table>
{{ form.as_table }}
@@ -37,7 +37,7 @@
<p style="color: red;">
Please correct the error{{ powerzonesform.errors|pluralize }} below.
{{ powerzonesform.non_field_errors }}
</p>
{% endif %}
<table>
@@ -89,7 +89,7 @@
<p>The OTW Power Slack is the percentage drop of your On-the-water
rowing power
vs the erg power. Typical values are around 15%. This will lower
the power zones for your OTW workouts.</p>
the power zones for your OTW workouts.</p>
<table>
{{ powerform.as_table }}
</table>
@@ -97,6 +97,20 @@
<input type="submit" value="Update">
</form>
</li>
<li class="grid_2">
<form enctype="multipart/form-data" action="" method="post">
<h2>Range over which Critical Power rolling data (fitness) are calculated</h2>
<p>Use this form to change the number of weeks over which Rowsandall
keeps track of your Critical Power. </p>
<p>A shorter range will give you notifications of fitness improvements more often,
but will also quickly forget those breakthrough workouts.</p>
<table>
{{ cpform.as_table }}
</table>
{% csrf_token %}
<input type="submit" value="Update">
</form>
</li>
</ul>

View File

@@ -120,7 +120,7 @@ from rowers.models import (
VirtualRaceFollower,
)
from rowers.models import (
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
RowerPowerForm,RowerForm,RowerCPForm,GraphImage,AdvancedWorkoutForm,
RowerPowerZonesForm,AccountRowerForm,UserForm,
Team,TeamForm,TeamInviteForm,TeamInvite,TeamRequest,
WorkoutComment,WorkoutCommentForm,RowerExportForm,

View File

@@ -480,6 +480,7 @@ def rower_prefs_view(request,userid=0,message=""):
form = RowerForm(instance=r)
powerform = RowerPowerForm(instance=r)
powerzonesform = RowerPowerZonesForm(instance=r)
cpform = RowerCPForm(instance=r)
if request.method == 'POST' and "ut2" in request.POST:
form = RowerForm(request.POST)
@@ -557,6 +558,14 @@ def rower_prefs_view(request,userid=0,message=""):
r.save()
successmessage = "Your Power Zone data were changed"
messages.info(request,successmessage)
elif request.method == 'POST' and 'cprange' in request.POST:
cpform = RowerCPForm(request.POST)
if cpform.is_valid():
cd = cpform.cleaned_data
cprange = cd['cprange']
r.cprange = cprange
r.save()
messages.info(request,'Updated CP range value')
return render(request, 'rower_preferences.html',
{
@@ -565,6 +574,7 @@ def rower_prefs_view(request,userid=0,message=""):
'powerform':powerform,
'powerzonesform':powerzonesform,
'breadcrumbs':breadcrumbs,
'cpform':cpform,
'rower':r,
})