user prefernces - continue urls.py line 381
This commit is contained in:
@@ -13,8 +13,18 @@
|
|||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li id="manage-prefs">
|
<li id="manage-prefs">
|
||||||
<a href="/me/preferences">
|
<a href="rowers/me/preferences/">
|
||||||
<i class="fas fa-cog fa-fw"></i> Preferences
|
<i class="fas fa-cog fa-fw"></i> Zones
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li id="manage-favs">
|
||||||
|
<a href="/rowers/me/favoritecharts">
|
||||||
|
<i class="fas fa-chart-area fa-fw"></i> Favorite Charts
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li id="manage-workflow">
|
||||||
|
<a href="/rowers/me/workflowconfig2">
|
||||||
|
<i class="fas fa-tachometer-alt-slow fa-fw"></i> Manage Workflow
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</ul><!-- cd-accordion-menu -->
|
</ul><!-- cd-accordion-menu -->
|
||||||
|
|||||||
@@ -1,117 +1,25 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "newbase.html" %}
|
||||||
{% load staticfiles %}
|
{% load staticfiles %}
|
||||||
{% load rowerfilters %}
|
{% load rowerfilters %}
|
||||||
|
|
||||||
{% block title %}Change Rower {% endblock %}
|
{% block title %}Change Rower {% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block main %}
|
||||||
<div class="grid_12 alpha">
|
<h1>User Settings for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||||
<div class="grid_8 alpha">
|
|
||||||
<h1>User Settings for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
<p><a href="http://analytics.rowsandall.com/2017/11/02/rowsandall-settings-page-tutorial/">Need help? Click to read the tutorial</a></p>
|
||||||
<p><a href="http://analytics.rowsandall.com/2017/11/02/rowsandall-settings-page-tutorial/">Need help? Click to read the tutorial</a></p>
|
|
||||||
</div>
|
<ul class="main-content">
|
||||||
<div class="grid_2 suffix_2 omega dropdown">
|
<li class="grid_2">
|
||||||
<button class="grid_2 alpha button green small dropbtn">
|
<h2>Account Information</h2>
|
||||||
{{ rower.user.first_name }} {{ rower.user.last_name }}
|
|
||||||
</button>
|
|
||||||
<div class="dropdown-content">
|
|
||||||
{% for rower in user|team_rowers %}
|
|
||||||
<a class="button green small" href="/rowers/rower/edit/{{ rower.id }}">{{ rower.user.first_name }} {{ rower.user.last_name }}</a>
|
|
||||||
{% endfor %}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="grid_6 alpha">
|
|
||||||
<p>
|
<p>
|
||||||
<h2>Heart Rate Zones</h2>
|
{% if rower.user == user %}
|
||||||
<p>Set your heart rate zones with this form.</p>
|
<a class="button blue small" href="/password_change/">Password Change</a>
|
||||||
{% if form.errors %}
|
{% else %}
|
||||||
<p style="color: red;">
|
|
||||||
Please correct the error{{ form.errors|pluralize }} below.
|
{% endif %}
|
||||||
</p>
|
</p>
|
||||||
{% endif %}
|
{% if userform.errors %}
|
||||||
|
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
|
||||||
<table>
|
|
||||||
{{ form.as_table }}
|
|
||||||
</table>
|
|
||||||
{% csrf_token %}
|
|
||||||
<div class="grid_2 prefix_2 suffix_2">
|
|
||||||
<input class="button green" type="submit" value="Save">
|
|
||||||
</form>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="grid_6 omega">
|
|
||||||
<p>
|
|
||||||
<h2>Power Zones</h2>
|
|
||||||
<p>The power zones are defined relative to power as measured by the
|
|
||||||
indoor rower.</p>
|
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
|
||||||
{% if powerzonesform.errors %}
|
|
||||||
<p style="color: red;">
|
|
||||||
Please correct the error{{ powerzonesform.errors|pluralize }} below.
|
|
||||||
{{ powerzonesform.non_field_errors }}
|
|
||||||
|
|
||||||
</p>
|
|
||||||
{% endif %}
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>ID</th><th>Zone Name</th><th>Lower Boundary (Watt)</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>1</td><td>{{ powerzonesform.ut3name }}</td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>2</td><td>{{ powerzonesform.ut2name }}</td>
|
|
||||||
<td>{{ powerzonesform.pw_ut2 }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>3</td><td>{{ powerzonesform.ut1name }}</td>
|
|
||||||
<td>{{ powerzonesform.pw_ut1 }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>4</td><td>{{ powerzonesform.atname }}</td>
|
|
||||||
<td>{{ powerzonesform.pw_at }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>5</td><td>{{ powerzonesform.trname }}</td>
|
|
||||||
<td>{{ powerzonesform.pw_tr }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>6</td><td>{{ powerzonesform.anname }}</td>
|
|
||||||
<td>{{ powerzonesform.pw_an }}</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
{% csrf_token %}
|
|
||||||
<div class="grid_2 prefix_2 suffix_2">
|
|
||||||
<input class="button green" type="submit" value="Save">
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="grid_12 alpha">
|
|
||||||
<div class="grid_6 alpha">
|
|
||||||
<p>
|
|
||||||
<h2>Account Information</h2>
|
|
||||||
<div class="grid_6 alpha">
|
|
||||||
<div class="grid_2 suffix_4 alpha">
|
|
||||||
<p>
|
|
||||||
{% if rower.user == user %}
|
|
||||||
<a class="button gray small" href="/password_change/">Password Change</a>
|
|
||||||
{% else %}
|
|
||||||
|
|
||||||
{% endif %}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</p>
|
|
||||||
{% if userform.errors %}
|
|
||||||
<p style="color: red;">
|
<p style="color: red;">
|
||||||
Please correct the error{{ form.errors|pluralize }} below.
|
Please correct the error{{ form.errors|pluralize }} below.
|
||||||
</p>
|
</p>
|
||||||
@@ -133,137 +41,59 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<div class="grid_2 alpha">
|
{% if rower.rowerplan == 'basic' and rower.user == user %}
|
||||||
{% if rower.rowerplan == 'basic' and rower.user == user %}
|
<a class="button blue" href="/rowers/promembership">Upgrade</a>
|
||||||
<a class="button blue" href="/rowers/promembership">Upgrade</a>
|
{% else %}
|
||||||
{% else %}
|
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
<input class="button green" type="submit" value="Save">
|
||||||
</div>
|
|
||||||
<div class="grid_2 suffix_2 omega">
|
|
||||||
<input class="button green" type="submit" value="Save">
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</li>
|
||||||
|
{% if rower.user == user %}
|
||||||
|
<li class="grid_2">
|
||||||
</p>
|
<h2>GDPR - Data Protection</h2>
|
||||||
</div>
|
|
||||||
<div class="grid_6 omega">
|
|
||||||
<p>
|
<p>
|
||||||
<h2>Functional Threshold Power and OTW Slack</h2>
|
<a class="button blue small" href="/rowers/exportallworkouts">Download your data</a>
|
||||||
<p>Use this form to quickly change your zones based on the power of a
|
|
||||||
recent
|
|
||||||
full out 60 minutes effort on the ergometer.
|
|
||||||
It will update all zones defined above.</p>
|
|
||||||
<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>
|
|
||||||
<form enctype="multipart/form-data" action="" method="post">
|
|
||||||
<table>
|
|
||||||
{{ powerform.as_table }}
|
|
||||||
</table>
|
|
||||||
{% csrf_token %}
|
|
||||||
<div class="grid_2 prefix_2 suffix_2">
|
|
||||||
<input class="button green" type="submit" value="Save">
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% if rower.user == user %}
|
|
||||||
<div class="grid_12 alpha">
|
|
||||||
<div class="grid_6 alpha">
|
|
||||||
<p>
|
|
||||||
<h2>Teams</h2>
|
|
||||||
<div class="grid_2 suffix_4 alpha">
|
|
||||||
<a class="button gray small" href="/rowers/me/teams">Manage Teams</a>
|
|
||||||
</div>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid_6 omega">
|
|
||||||
<p>
|
<p>
|
||||||
<h2>Favorite Charts</h2>
|
<a class="button blue small" href="/rowers/me/deactivate">Deactivate Account</a>
|
||||||
<div class="grid_2 suffix_4 alpha">
|
|
||||||
<a class="button gray small" href="/rowers/me/favoritecharts">Manage Favorite Charts</a>
|
|
||||||
</div>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="grid_12 alpha">
|
|
||||||
<div class="grid_6 alpha">
|
|
||||||
<p>
|
<p>
|
||||||
<h2>Export Settings</h2>
|
<a class="button red small" href="/rowers/me/delete">Delete Account</a>
|
||||||
<div class="grid_2 suffix_4 alpha">
|
|
||||||
<a class="button gray small" href="/rowers/me/exportsettings">Manage Export Settings</a>
|
|
||||||
</div>
|
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</li>
|
||||||
<div class="grid_6 omega">
|
<li class="grid_2">
|
||||||
<p>
|
|
||||||
<h2>Configure Workflow Layout</h2>
|
|
||||||
<div class="grid_2 suffix_4 alpha">
|
|
||||||
<a class="button gray small" href="/rowers/me/workflowconfig2">Manage Workflow Layout</a>
|
|
||||||
</div>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="grid_12 alpha">
|
|
||||||
<div class="grid_6 alpha">
|
|
||||||
<p>
|
|
||||||
<h2>GDPR - Data Protection</h2>
|
|
||||||
<div class="grid_2 suffix_4 alpha">
|
|
||||||
<p>
|
|
||||||
<a class="button gray small" href="/rowers/exportallworkouts">Download your data</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="grid_2 suffix_4 alpha">
|
|
||||||
<p>
|
|
||||||
<a class="button gray small" href="/rowers/me/deactivate">Deactivate Account</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="grid_2 suffix_4 alpha">
|
|
||||||
<p>
|
|
||||||
<a class="button red small" href="/rowers/me/delete">Delete Account</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="grid_6 omega">
|
|
||||||
{% if grants %}
|
{% if grants %}
|
||||||
<p>
|
<h2>Applications</h2>
|
||||||
<h2>Applications</h2>
|
<table width="100%">
|
||||||
<table width="100%">
|
<thead>
|
||||||
<thead>
|
<tr>
|
||||||
<tr>
|
<th>Application</th>
|
||||||
<th>Application</th>
|
<th>Scope</th>
|
||||||
<th>Scope</th>
|
<th>Revoke</th>
|
||||||
<th>Revoke</th>
|
</tr>
|
||||||
</tr>
|
</thead>
|
||||||
</thead>
|
<tbody>
|
||||||
<tbody>
|
{% for grant in grants %}
|
||||||
{% for grant in grants %}
|
<tr>
|
||||||
<tr>
|
<td>{{ grant.application }}</td>
|
||||||
<td>{{ grant.application }}</td>
|
<td>{{ grant.scope }}</td>
|
||||||
<td>{{ grant.scope }}</td>
|
<td>
|
||||||
<td>
|
<a class="button red small" href="/rowers/me/revokeapp/{{ grant.application.id }}">Revoke</a>
|
||||||
<a class="button red small" href="/rowers/me/revokeapp/{{ grant.application.id }}">Revoke</a>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</p>
|
|
||||||
{% else %}
|
|
||||||
<p> </p>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</li>
|
||||||
</div>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_profile.html' %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
108
rowers/templates/rower_preferences.html
Normal file
108
rowers/templates/rower_preferences.html
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
{% extends "newbase.html" %}
|
||||||
|
{% load staticfiles %}
|
||||||
|
{% load rowerfilters %}
|
||||||
|
|
||||||
|
{% block title %}Change Rower Preferences{% endblock %}
|
||||||
|
|
||||||
|
{% block main %}
|
||||||
|
<h1>User Preferences for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||||
|
|
||||||
|
<p><a href="http://analytics.rowsandall.com/2017/11/02/rowsandall-settings-page-tutorial/">Need help? Click to read the tutorial</a></p>
|
||||||
|
|
||||||
|
<ul class="main-content">
|
||||||
|
<li class="grid_2">
|
||||||
|
<p>
|
||||||
|
<h2>Heart Rate Zones</h2>
|
||||||
|
<p>Set your heart rate zones with this form.</p>
|
||||||
|
{% if form.errors %}
|
||||||
|
<p style="color: red;">
|
||||||
|
Please correct the error{{ form.errors|pluralize }} below.
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
|
<table>
|
||||||
|
{{ form.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<input class="button green" type="submit" value="Save">
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
<li class="grid_2">
|
||||||
|
<h2>Power Zones</h2>
|
||||||
|
<p>The power zones are defined relative to power as measured by the
|
||||||
|
indoor rower.</p>
|
||||||
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
|
{% if powerzonesform.errors %}
|
||||||
|
<p style="color: red;">
|
||||||
|
Please correct the error{{ powerzonesform.errors|pluralize }} below.
|
||||||
|
{{ powerzonesform.non_field_errors }}
|
||||||
|
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th><th>Zone Name</th><th>Lower Boundary (Watt)</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>1</td><td>{{ powerzonesform.ut3name }}</td>
|
||||||
|
<td></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>2</td><td>{{ powerzonesform.ut2name }}</td>
|
||||||
|
<td>{{ powerzonesform.pw_ut2 }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>3</td><td>{{ powerzonesform.ut1name }}</td>
|
||||||
|
<td>{{ powerzonesform.pw_ut1 }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>4</td><td>{{ powerzonesform.atname }}</td>
|
||||||
|
<td>{{ powerzonesform.pw_at }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>5</td><td>{{ powerzonesform.trname }}</td>
|
||||||
|
<td>{{ powerzonesform.pw_tr }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>6</td><td>{{ powerzonesform.anname }}</td>
|
||||||
|
<td>{{ powerzonesform.pw_an }}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<div class="grid_2 prefix_2 suffix_2">
|
||||||
|
<input class="button green" type="submit" value="Save">
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
<li class="grid_2">
|
||||||
|
<h2>Functional Threshold Power and OTW Slack</h2>
|
||||||
|
<p>Use this form to quickly change your zones based on the power of a
|
||||||
|
recent
|
||||||
|
full out 60 minutes effort on the ergometer.
|
||||||
|
It will update all zones defined above.</p>
|
||||||
|
<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>
|
||||||
|
<form enctype="multipart/form-data" action="" method="post">
|
||||||
|
<table>
|
||||||
|
{{ powerform.as_table }}
|
||||||
|
</table>
|
||||||
|
{% csrf_token %}
|
||||||
|
<input class="button green" type="submit" value="Save">
|
||||||
|
</form>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include 'menu_profile.html' %}
|
||||||
|
{% endblock %}
|
||||||
@@ -361,6 +361,8 @@ urlpatterns = [
|
|||||||
url(r'^me/request/$',views.manager_requests_view),
|
url(r'^me/request/$',views.manager_requests_view),
|
||||||
url(r'^me/edit/$',views.rower_edit_view),
|
url(r'^me/edit/$',views.rower_edit_view),
|
||||||
url(r'^me/edit/user/(?P<userid>\d+)$',views.rower_edit_view),
|
url(r'^me/edit/user/(?P<userid>\d+)$',views.rower_edit_view),
|
||||||
|
url(r'^me/preferences/$',views.rower_prefs_view),
|
||||||
|
url(r'^me/preferences/user/(?P<userid>\d+)$',views.rower_prefs_view),
|
||||||
url(r'^me/edit/(.+.*)/$',views.rower_edit_view),
|
url(r'^me/edit/(.+.*)/$',views.rower_edit_view),
|
||||||
url(r'^me/c2authorize/$',views.rower_c2_authorize),
|
url(r'^me/c2authorize/$',views.rower_c2_authorize),
|
||||||
url(r'^me/polarauthorize/$',views.rower_polar_authorize),
|
url(r'^me/polarauthorize/$',views.rower_polar_authorize),
|
||||||
@@ -375,7 +377,7 @@ urlpatterns = [
|
|||||||
url(r'^me/tprefresh/$',views.rower_tp_token_refresh),
|
url(r'^me/tprefresh/$',views.rower_tp_token_refresh),
|
||||||
url(r'^me/c2refresh/$',views.rower_c2_token_refresh),
|
url(r'^me/c2refresh/$',views.rower_c2_token_refresh),
|
||||||
url(r'^me/favoritecharts/$',views.rower_favoritecharts_view),
|
url(r'^me/favoritecharts/$',views.rower_favoritecharts_view),
|
||||||
url(r'^me/workflowconfig$',views.workout_workflow_config_view),
|
# url(r'^me/workflowconfig$',views.workout_workflow_config_view),
|
||||||
url(r'^me/workflowconfig2$',views.workout_workflow_config2_view),
|
url(r'^me/workflowconfig2$',views.workout_workflow_config2_view),
|
||||||
url(r'^me/workflowdefault$',views.workflow_default_view),
|
url(r'^me/workflowdefault$',views.workflow_default_view),
|
||||||
url(r'^email/send/$', views.sendmail),
|
url(r'^email/send/$', views.sendmail),
|
||||||
|
|||||||
295
rowers/views.py
295
rowers/views.py
@@ -11927,7 +11927,7 @@ def rower_edit_view(request,rowerid=0,userid=0,message=""):
|
|||||||
r = getrequestrower(request,rowerid=rowerid,userid=userid,notpermanent=True)
|
r = getrequestrower(request,rowerid=rowerid,userid=userid,notpermanent=True)
|
||||||
|
|
||||||
rowerid = r.id
|
rowerid = r.id
|
||||||
|
|
||||||
if request.method == 'POST' and "ut2" in request.POST:
|
if request.method == 'POST' and "ut2" in request.POST:
|
||||||
form = RowerForm(request.POST)
|
form = RowerForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
@@ -12018,7 +12018,7 @@ def rower_edit_view(request,rowerid=0,userid=0,message=""):
|
|||||||
messages.info(request,message)
|
messages.info(request,message)
|
||||||
url = reverse(rower_edit_view,
|
url = reverse(rower_edit_view,
|
||||||
kwargs = {
|
kwargs = {
|
||||||
'rowerid':r.id,
|
'userid':r.user.id,
|
||||||
})
|
})
|
||||||
response = HttpResponseRedirect(url)
|
response = HttpResponseRedirect(url)
|
||||||
except Rower.DoesNotExist:
|
except Rower.DoesNotExist:
|
||||||
@@ -12202,6 +12202,288 @@ def rower_edit_view(request,rowerid=0,userid=0,message=""):
|
|||||||
except Rower.DoesNotExist:
|
except Rower.DoesNotExist:
|
||||||
raise Http404("This user doesn't exist")
|
raise Http404("This user doesn't exist")
|
||||||
|
|
||||||
|
# Page where user can set his details
|
||||||
|
# Add email address to form so user can change his email address
|
||||||
|
@login_required()
|
||||||
|
def rower_prefs_view(request,rowerid=0,userid=0,message=""):
|
||||||
|
r = getrequestrower(request,rowerid=rowerid,userid=userid,notpermanent=True)
|
||||||
|
|
||||||
|
rowerid = r.id
|
||||||
|
|
||||||
|
if request.method == 'POST' and "ut2" in request.POST:
|
||||||
|
form = RowerForm(request.POST)
|
||||||
|
if form.is_valid():
|
||||||
|
# something
|
||||||
|
cd = form.cleaned_data
|
||||||
|
hrmax = cd['max']
|
||||||
|
ut2 = cd['ut2']
|
||||||
|
ut1 = cd['ut1']
|
||||||
|
at = cd['at']
|
||||||
|
tr = cd['tr']
|
||||||
|
an = cd['an']
|
||||||
|
rest = cd['rest']
|
||||||
|
try:
|
||||||
|
r.max = max(min(hrmax,250),10)
|
||||||
|
r.ut2 = max(min(ut2,250),10)
|
||||||
|
r.ut1 = max(min(ut1,250),10)
|
||||||
|
r.at = max(min(at,250),10)
|
||||||
|
r.tr = max(min(tr,250),10)
|
||||||
|
r.an = max(min(an,250),10)
|
||||||
|
r.rest = max(min(rest,250),10)
|
||||||
|
r.save()
|
||||||
|
successmessage = "Your Heart Rate data were changed"
|
||||||
|
messages.info(request,successmessage)
|
||||||
|
form = RowerForm(instance=r)
|
||||||
|
powerform = RowerPowerForm(instance=r)
|
||||||
|
powerzonesform = RowerPowerZonesForm(instance=r)
|
||||||
|
accountform = AccountRowerForm(instance=r)
|
||||||
|
userform = UserForm(instance=r.user)
|
||||||
|
return render(request, 'rower_preferences.html',
|
||||||
|
{'form':form,
|
||||||
|
'powerzonesform':powerzonesform,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
'powerform':powerform,
|
||||||
|
'rower':r,
|
||||||
|
'accountform':accountform,
|
||||||
|
'userform':userform,
|
||||||
|
})
|
||||||
|
except Rower.DoesNotExist:
|
||||||
|
message = "Funny. This user doesn't exist."
|
||||||
|
messages.error(request,message)
|
||||||
|
url = reverse(workouts_view)
|
||||||
|
response = HttpResponseRedirect(url)
|
||||||
|
else:
|
||||||
|
message = HttpResponse("invalid form")
|
||||||
|
#form = RowerForm(instance=r)
|
||||||
|
powerform = RowerPowerForm(instance=r)
|
||||||
|
powerzonesform = RowerPowerZonesForm(instance=r)
|
||||||
|
userform = UserForm(instance=r.user)
|
||||||
|
accountform = AccountRowerForm(instance=r)
|
||||||
|
return render(request, 'rower_preferences.html',
|
||||||
|
{'form':form,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
'powerzonesform':powerzonesform,
|
||||||
|
'userform':userform,
|
||||||
|
'accountform':accountform,
|
||||||
|
'powerform':powerform,
|
||||||
|
'rower':r,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
return response
|
||||||
|
elif request.method == 'POST' and "ftp" in request.POST:
|
||||||
|
powerform = RowerPowerForm(request.POST)
|
||||||
|
if powerform.is_valid():
|
||||||
|
cd = powerform.cleaned_data
|
||||||
|
hrftp = cd['hrftp']
|
||||||
|
if hrftp == 0:
|
||||||
|
hrftp = int((r.an+r.tr)/2.)
|
||||||
|
ftp = cd['ftp']
|
||||||
|
otwslack = cd['otwslack']
|
||||||
|
try:
|
||||||
|
powerfrac = 100*np.array([r.pw_ut2,
|
||||||
|
r.pw_ut1,
|
||||||
|
r.pw_at,
|
||||||
|
r.pw_tr,r.pw_an])/r.ftp
|
||||||
|
r.ftp = max(min(ftp,650),50)
|
||||||
|
r.otwslack = max(min(otwslack,50),0)
|
||||||
|
ut2,ut1,at,tr,an = (r.ftp*powerfrac/100.).astype(int)
|
||||||
|
r.pw_ut2 = ut2
|
||||||
|
r.pw_ut1 = ut1
|
||||||
|
r.pw_at = at
|
||||||
|
r.pw_tr = tr
|
||||||
|
r.pw_an = an
|
||||||
|
r.hrftp = hrftp
|
||||||
|
r.save()
|
||||||
|
message = "FTP and/or OTW slack values changed."
|
||||||
|
messages.info(request,message)
|
||||||
|
url = reverse(rower_prefs_view,
|
||||||
|
kwargs = {
|
||||||
|
'userid':r.user.id,
|
||||||
|
})
|
||||||
|
response = HttpResponseRedirect(url)
|
||||||
|
except Rower.DoesNotExist:
|
||||||
|
message = "Funny. This user doesn't exist."
|
||||||
|
messages.error(request,message)
|
||||||
|
url = reverse(rower_edit_view)
|
||||||
|
response = HttpResponseRedirect(url)
|
||||||
|
else:
|
||||||
|
message = HttpResponse("invalid form")
|
||||||
|
form = RowerForm(instance=r)
|
||||||
|
#powerform = RowerPowerForm(instance=r)
|
||||||
|
powerzonesform = RowerPowerZonesForm(instance=r)
|
||||||
|
userform = UserForm(instance=r.user)
|
||||||
|
accountform = AccountRowerForm(instance=r)
|
||||||
|
return render(request, 'rower_preferences.html',
|
||||||
|
{'form':form,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
'powerform':powerform,
|
||||||
|
'rower':r,
|
||||||
|
'userform':userform,
|
||||||
|
'accountform':accountform,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
return response
|
||||||
|
elif request.method == 'POST' and "ut3name" in request.POST:
|
||||||
|
powerzonesform = RowerPowerZonesForm(request.POST)
|
||||||
|
if powerzonesform.is_valid():
|
||||||
|
cd = powerzonesform.cleaned_data
|
||||||
|
pw_ut2 = cd['pw_ut2']
|
||||||
|
pw_ut1 = cd['pw_ut1']
|
||||||
|
pw_at = cd['pw_at']
|
||||||
|
pw_tr = cd['pw_tr']
|
||||||
|
pw_an = cd['pw_an']
|
||||||
|
ut3name = cd['ut3name']
|
||||||
|
ut2name = cd['ut2name']
|
||||||
|
ut1name = cd['ut1name']
|
||||||
|
atname = cd['atname']
|
||||||
|
trname = cd['trname']
|
||||||
|
anname = cd['anname']
|
||||||
|
powerzones = [ut3name,ut2name,ut1name,atname,trname,anname]
|
||||||
|
try:
|
||||||
|
r.pw_ut2 = pw_ut2
|
||||||
|
r.pw_ut1 = pw_ut1
|
||||||
|
r.pw_at = pw_at
|
||||||
|
r.pw_tr = pw_tr
|
||||||
|
r.pw_an = pw_an
|
||||||
|
r.powerzones = powerzones
|
||||||
|
r.save()
|
||||||
|
successmessage = "Your Power Zone data were changed"
|
||||||
|
messages.info(request,successmessage)
|
||||||
|
form = RowerForm(instance=r)
|
||||||
|
accountform = AccountRowerForm(instance=r)
|
||||||
|
userform = UserForm(instance=r.user)
|
||||||
|
powerform = RowerPowerForm(instance=r)
|
||||||
|
powerzonesform = RowerPowerZonesForm(instance=r)
|
||||||
|
return render(request, 'rower_preferences.html',
|
||||||
|
{'form':form,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
'powerzonesform':powerzonesform,
|
||||||
|
'powerform':powerform,
|
||||||
|
'userform':userform,
|
||||||
|
'accountform':accountform,
|
||||||
|
'rower':r,
|
||||||
|
})
|
||||||
|
except Rower.DoesNotExist:
|
||||||
|
message = "Funny. This user doesn't exist."
|
||||||
|
messages.error(request,message)
|
||||||
|
url = reverse(workouts_view)
|
||||||
|
response = HttpResponseRedirect(url)
|
||||||
|
return response
|
||||||
|
else:
|
||||||
|
form = RowerForm(instance=r)
|
||||||
|
powerform = RowerPowerForm(instance=r)
|
||||||
|
accountform = AccountRowerForm(instance=r)
|
||||||
|
userform = UserForm(instance=r.user)
|
||||||
|
#powerzonesform = RowerPowerZonesForm(instance=r)
|
||||||
|
message = HttpResponse("invalid form")
|
||||||
|
return render(request, 'rower_preferences.html',
|
||||||
|
{'form':form,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
'powerform':powerform,
|
||||||
|
'powerzonesform':powerzonesform,
|
||||||
|
'accountform':accountform,
|
||||||
|
'userform':userform,
|
||||||
|
'rower':r,
|
||||||
|
})
|
||||||
|
elif request.method == 'POST' and "weightcategory" in request.POST:
|
||||||
|
accountform = AccountRowerForm(request.POST)
|
||||||
|
userform = UserForm(request.POST,instance=r.user)
|
||||||
|
if accountform.is_valid() and userform.is_valid():
|
||||||
|
# process
|
||||||
|
cd = accountform.cleaned_data
|
||||||
|
ucd = userform.cleaned_data
|
||||||
|
first_name = ucd['first_name']
|
||||||
|
last_name = ucd['last_name']
|
||||||
|
email = ucd['email']
|
||||||
|
sex = cd['sex']
|
||||||
|
defaultlandingpage = cd['defaultlandingpage']
|
||||||
|
weightcategory = cd['weightcategory']
|
||||||
|
birthdate = cd['birthdate']
|
||||||
|
showfavoritechartnotes = cd['showfavoritechartnotes']
|
||||||
|
getemailnotifications = cd['getemailnotifications']
|
||||||
|
getimportantemails = cd['getimportantemails']
|
||||||
|
defaulttimezone=cd['defaulttimezone']
|
||||||
|
u = r.user
|
||||||
|
if u.email != email and len(email):
|
||||||
|
resetbounce = True
|
||||||
|
else:
|
||||||
|
resetbounce = False
|
||||||
|
if len(first_name):
|
||||||
|
u.first_name = first_name
|
||||||
|
u.last_name = last_name
|
||||||
|
if len(email): ## and check_email_freeforuse(u,email):
|
||||||
|
u.email = email
|
||||||
|
resetbounce = True
|
||||||
|
|
||||||
|
|
||||||
|
u.save()
|
||||||
|
r.defaulttimezone=defaulttimezone
|
||||||
|
r.weightcategory = weightcategory
|
||||||
|
r.getemailnotifications = getemailnotifications
|
||||||
|
r.getimportantemails = getimportantemails
|
||||||
|
r.defaultlandingpage = defaultlandingpage
|
||||||
|
r.showfavoritechartnotes = showfavoritechartnotes
|
||||||
|
r.sex = sex
|
||||||
|
r.birthdate = birthdate
|
||||||
|
if resetbounce and r.emailbounced:
|
||||||
|
r.emailbounced = False
|
||||||
|
r.save()
|
||||||
|
form = RowerForm(instance=r)
|
||||||
|
powerform = RowerPowerForm(instance=r)
|
||||||
|
powerzonesform = RowerPowerZonesForm(instance=r)
|
||||||
|
accountform = AccountRowerForm(instance=r)
|
||||||
|
userform = UserForm(instance=u)
|
||||||
|
successmessage = 'Account Information changed'
|
||||||
|
messages.info(request,successmessage)
|
||||||
|
return render(request, 'rower_preferences.html',
|
||||||
|
{'form':form,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
'powerzonesform':powerzonesform,
|
||||||
|
'powerform':powerform,
|
||||||
|
'accountform':accountform,
|
||||||
|
'userform':userform,
|
||||||
|
'rower':r,
|
||||||
|
})
|
||||||
|
else:
|
||||||
|
form = RowerForm(instance=r)
|
||||||
|
powerform = RowerPowerForm(instance=r)
|
||||||
|
powerzonesform = RowerPowerZonesForm(instance=r)
|
||||||
|
return render(request, 'rower_preferences.html',
|
||||||
|
{'form':form,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
'powerzonesform':powerzonesform,
|
||||||
|
'powerform':powerform,
|
||||||
|
'accountform':accountform,
|
||||||
|
'userform':userform,
|
||||||
|
'rower':r,
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
form = RowerForm(instance=r)
|
||||||
|
powerform = RowerPowerForm(instance=r)
|
||||||
|
powerzonesform = RowerPowerZonesForm(instance=r)
|
||||||
|
accountform = AccountRowerForm(instance=r)
|
||||||
|
userform = UserForm(instance=r.user)
|
||||||
|
grants = AccessToken.objects.filter(user=request.user)
|
||||||
|
return render(request, 'rower_preferences.html',
|
||||||
|
{
|
||||||
|
'form':form,
|
||||||
|
'teams':get_my_teams(request.user),
|
||||||
|
'powerform':powerform,
|
||||||
|
'powerzonesform':powerzonesform,
|
||||||
|
'userform':userform,
|
||||||
|
'accountform':accountform,
|
||||||
|
'grants':grants,
|
||||||
|
'rower':r,
|
||||||
|
})
|
||||||
|
except Rower.DoesNotExist:
|
||||||
|
raise Http404("This user doesn't exist")
|
||||||
|
|
||||||
# Revoke an app that you granted access through the API.
|
# Revoke an app that you granted access through the API.
|
||||||
# this views is called when you press a button on the User edit page
|
# this views is called when you press a button on the User edit page
|
||||||
# the button is only there when you have granted access to an app
|
# the button is only there when you have granted access to an app
|
||||||
@@ -12219,13 +12501,8 @@ def rower_revokeapp_view(request,id=0):
|
|||||||
form = RowerForm(instance=r)
|
form = RowerForm(instance=r)
|
||||||
powerform = RowerPowerForm(instance=r)
|
powerform = RowerPowerForm(instance=r)
|
||||||
grants = AccessToken.objects.filter(user=request.user)
|
grants = AccessToken.objects.filter(user=request.user)
|
||||||
return render(request, 'rower_form.html',
|
url = reverse(rower_edit_view)
|
||||||
{
|
return HttpResponseRedirect(url)
|
||||||
'form':form,
|
|
||||||
'teams':get_my_teams(request.user),
|
|
||||||
'powerform':powerform,
|
|
||||||
'grants':grants,
|
|
||||||
})
|
|
||||||
except AccessToken.DoesNotExist:
|
except AccessToken.DoesNotExist:
|
||||||
raise Http404("Access token doesn't exist")
|
raise Http404("Access token doesn't exist")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user