fine tuning
This commit is contained in:
@@ -49,7 +49,7 @@ class PlannedSessionAdmin(admin.ModelAdmin):
|
||||
|
||||
class GraphImageAdmin(admin.ModelAdmin):
|
||||
list_display = ('creationdatetime','workout','filename')
|
||||
|
||||
|
||||
admin.site.unregister(User)
|
||||
admin.site.register(User,UserAdmin)
|
||||
admin.site.register(Workout,WorkoutAdmin)
|
||||
|
||||
@@ -797,7 +797,7 @@ class PlannedSession(models.Model):
|
||||
)
|
||||
|
||||
criteriumchoices = (
|
||||
('none','None'),
|
||||
('none','Approximately'),
|
||||
('minimum','At Least'),
|
||||
('exact','Exactly'),
|
||||
)
|
||||
@@ -879,6 +879,9 @@ class PlannedSession(models.Model):
|
||||
|
||||
return stri
|
||||
|
||||
# Date input utility
|
||||
class DateInput(forms.DateInput):
|
||||
input_type = 'date'
|
||||
|
||||
class PlannedSessionForm(ModelForm):
|
||||
class Meta:
|
||||
@@ -888,19 +891,16 @@ class PlannedSessionForm(ModelForm):
|
||||
'name',
|
||||
'sessiontype',
|
||||
'sessionmode',
|
||||
'criterium',
|
||||
'sessionvalue',
|
||||
'sessionunit',
|
||||
'comment',
|
||||
]
|
||||
widgets = {
|
||||
'comment': forms.Textarea,
|
||||
'startdate': SelectDateWidget(
|
||||
years=range(
|
||||
timezone.now().year-1,timezone.now().year+2)),
|
||||
'enddate': SelectDateWidget(
|
||||
years=range(
|
||||
timezone.now().year-1,timezone.now().year+2)),
|
||||
}
|
||||
'startdate': DateInput(),
|
||||
'enddate': DateInput(),
|
||||
}
|
||||
|
||||
|
||||
# Workout
|
||||
@@ -1140,9 +1140,6 @@ def auto_delete_image_on_delete(sender,instance, **kwargs):
|
||||
else:
|
||||
print "couldn't find the file "+instance.filename
|
||||
|
||||
# Date input utility
|
||||
class DateInput(forms.DateInput):
|
||||
input_type = 'date'
|
||||
|
||||
# Form to update Workout data
|
||||
class WorkoutForm(ModelForm):
|
||||
|
||||
57
rowers/templates/planmembership.html
Normal file
57
rowers/templates/planmembership.html
Normal file
@@ -0,0 +1,57 @@
|
||||
|
||||
{% extends "base.html" %}
|
||||
{% block title %}About us{% endblock title %}
|
||||
{% block content %}
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
<h2>Coach and Self-Coach Membership</h2>
|
||||
|
||||
<p>You have arrived at this page, because you tried to create a
|
||||
training plan for yourself.</p>
|
||||
|
||||
<p>Currently, training planning is restricted to "coach" members with
|
||||
"team" functionality.</p>
|
||||
|
||||
<p>If you are interested in becoming a coach and planning sessions
|
||||
for a group of rowers on rowsandall.com, contact me through the contact
|
||||
form.
|
||||
</p>
|
||||
|
||||
<p>If you would like to find a coach who helps you plan your training
|
||||
through rowsandall.com, contact me throught the contact form.</p>
|
||||
|
||||
<p>For self-coached rowers who would like to add the training planning
|
||||
functionality, we will soon establish a "Self-Coach" plan, which will enable you to do so.</p>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
<div class="grid_6 omega">
|
||||
<h2>What training planning functionality do we offer?</h2>
|
||||
|
||||
<p>Over the spring of 2018, we will gradually expand this functionality.
|
||||
Our current roadmap is to deploy the following and more:</li>
|
||||
|
||||
<p>
|
||||
<ul>
|
||||
<li>Create Planned Sessions (trainings, tests, challenges) for yourself
|
||||
and for your team members (coach plan)</li>
|
||||
<li>Track your performance against plan.
|
||||
Match workouts to planned sessions.
|
||||
Get feedback on plan adherence.</li>
|
||||
<li>Track your teams performance against plan. See how well each
|
||||
of your team members adhere to their (team or personalized) plan.</li>
|
||||
<li>See test outcomes ranked by performance.</li>
|
||||
<li>Attach courses to your OTW tests. This advanced functionality
|
||||
allows you, for example, to assign "Row the 6km from bridge A to
|
||||
bridge B on Saturday" to your team members. The resulting workout
|
||||
tracks will be evaluated against the course, and you will receive
|
||||
a results table for the net time spent between the start and finish
|
||||
points on the course. It's like a mini head race.
|
||||
</ul>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
{% endblock content %}
|
||||
@@ -8,69 +8,105 @@
|
||||
{% include "planningbuttons.html" %}
|
||||
|
||||
</div>
|
||||
<div id="left" class="grid_6 alpha">
|
||||
<h1>Create a new Planned Session</h1>
|
||||
<div class="grid_12 alpha">
|
||||
<div id="left" class="grid_6 alpha">
|
||||
<h1>Create Session for {{ rower.user.first_name }} {{ rower.user.last_name }}</h1>
|
||||
</div>
|
||||
<div id="timeperiod" class="grid_2 dropdown">
|
||||
<button class="grid_2 alpha button gray small dropbtn">Time Period</button>
|
||||
<div class="dropdown-content">
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/today/rower/{{ rower.id }}">
|
||||
Today
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/thisweek/rower/{{ rower.id }}">
|
||||
This Week
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/thismonth/rower/{{ rower.id }}">
|
||||
This Month
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/lastweek/rower/{{ rower.id }}">
|
||||
Last Week
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/lastmonth/rower/{{ rower.id }}">
|
||||
Last Month
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div class="grid_6 alpha">
|
||||
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
<div id="formbutton" class="grid_1 prefix_4 suffix_1">
|
||||
<input class="button green" type="submit" value="Submit">
|
||||
</div>
|
||||
</div>
|
||||
<div id="right" class="grid_6 omega">
|
||||
<h1>Plan</h1>
|
||||
<p>
|
||||
Click on session name to view
|
||||
</p>
|
||||
<table class="listtable shortpadded" width="80%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>After</th>
|
||||
<th>Before</th>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
<th> </th>
|
||||
<th>Edit</th>
|
||||
<th>Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ps in plannedsessions %}
|
||||
<tr>
|
||||
<td> {{ ps.startdate|date:"Y-m-d" }} </td>
|
||||
<td> {{ ps.enddate|date:"Y-m-d" }} </td>
|
||||
<td>
|
||||
{% if ps.name != '' %}
|
||||
<a class="small"
|
||||
href="/rowers/sessions/{{ ps.id }}">{{ ps.name }}</a>
|
||||
{% else %}
|
||||
<a class="small"
|
||||
href="/rowers/sessions/{{ ps.id }}">Unnamed Session</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td> {{ ps.sessionvalue }} </td>
|
||||
<td> {{ ps.sessionunit }} </td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/edit">Edit</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/deleteconfirm">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="right" class="grid_6 omega">
|
||||
<h1>Plan</h1>
|
||||
<p>
|
||||
Click on session name to view
|
||||
</p>
|
||||
<table class="listtable shortpadded" width="80%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>After</th>
|
||||
<th>Before</th>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
<th> </th>
|
||||
<th>Edit</th>
|
||||
<th>Clone</th>
|
||||
<th>Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ps in plannedsessions %}
|
||||
<tr>
|
||||
<td> {{ ps.startdate|date:"Y-m-d" }} </td>
|
||||
<td> {{ ps.enddate|date:"Y-m-d" }} </td>
|
||||
<td>
|
||||
{% if ps.name != '' %}
|
||||
<a class="small"
|
||||
href="/rowers/sessions/{{ ps.id }}">{{ ps.name }}</a>
|
||||
{% else %}
|
||||
<a class="small"
|
||||
href="/rowers/sessions/{{ ps.id }}">Unnamed Session</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td> {{ ps.sessionvalue }} </td>
|
||||
<td> {{ ps.sessionunit }} </td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/edit">Edit</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/clone">Clone</a>
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/deleteconfirm">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -8,72 +8,116 @@
|
||||
{% include "planningbuttons.html" %}
|
||||
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div id="left" class="grid_6 alpha">
|
||||
<h1>Edit Session {{ thesession.name }}</h1>
|
||||
</div>
|
||||
<div id="timeperiod" class="grid_2 dropdown">
|
||||
<button class="grid_2 alpha button gray small dropbtn">Time Period</button>
|
||||
<div class="dropdown-content">
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/today/rower/{{ rower.id }}">
|
||||
Today
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/thisweek/rower/{{ rower.id }}">
|
||||
This Week
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/thismonth/rower/{{ rower.id }}">
|
||||
This Month
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/lastweek/rower/{{ rower.id }}">
|
||||
Last Week
|
||||
</a>
|
||||
<a class="button gray small alpha"
|
||||
href="/rowers/sessions/create/lastmonth/rower/{{ rower.id }}">
|
||||
Last Month
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid_12 alpha">
|
||||
<div class="grid_6 alpha">
|
||||
<form enctype="multipart/form-data" action="{{ formloc }}" method="post">
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
<div class="grid_1 prefix_3 alpha">
|
||||
<a class="red button small" href="/rowers/sessions/{{ thesession.id }}/deleteconfirm">Delete</a>
|
||||
</div>
|
||||
<div id="formbutton" class="grid_1 suffix_1 omega">
|
||||
<input class="button green" type="submit" value="Submit">
|
||||
</div>
|
||||
</div>
|
||||
<div id="right" class="grid_6 omega">
|
||||
<h1>Plan</h1>
|
||||
<p>
|
||||
Click on session name to view
|
||||
</p>
|
||||
<table class="listtable shortpadded" width="80%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>After</th>
|
||||
<th>Before</th>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
<th> </th>
|
||||
<th>Edit</th>
|
||||
<th>Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ps in plannedsessions %}
|
||||
<tr>
|
||||
<td> {{ ps.startdate|date:"Y-m-d" }} </td>
|
||||
<td> {{ ps.enddate|date:"Y-m-d" }} </td>
|
||||
<td>
|
||||
{% if ps.name != '' %}
|
||||
<a class="small"
|
||||
href="/rowers/sessions/{{ ps.id }}">{{ ps.name }}</a>
|
||||
{% else %}
|
||||
<a class="small"
|
||||
href="/rowers/sessions/{{ ps.id }}">Unnamed Session</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td> {{ ps.sessionvalue }} </td>
|
||||
<td> {{ ps.sessionunit }} </td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/edit">Edit</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/deleteconfirm">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% if form.errors %}
|
||||
<p style="color: red;">
|
||||
Please correct the error{{ form.errors|pluralize }} below.
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
{% csrf_token %}
|
||||
<div class="grid_1 prefix_2 alpha">
|
||||
<a class="red button small" href="/rowers/sessions/{{ thesession.id }}/deleteconfirm">Delete</a>
|
||||
</div>
|
||||
<div class="grid_1">
|
||||
<a class="gray button small" href="/rowers/sessions/{{ thesession.id }}/clone">Clone</a>
|
||||
</div>
|
||||
<div id="formbutton" class="grid_1 suffix_1 omega">
|
||||
<input class="button green" type="submit" value="Save">
|
||||
</div>
|
||||
</div>
|
||||
<div id="right" class="grid_6 omega">
|
||||
<h1>Plan</h1>
|
||||
<p>
|
||||
Click on session name to view
|
||||
</p>
|
||||
<table class="listtable shortpadded" width="80%">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>After</th>
|
||||
<th>Before</th>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
<th> </th>
|
||||
<th>Edit</th>
|
||||
<th>Clone</th>
|
||||
<th>Delete</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for ps in plannedsessions %}
|
||||
<tr>
|
||||
<td> {{ ps.startdate|date:"Y-m-d" }} </td>
|
||||
<td> {{ ps.enddate|date:"Y-m-d" }} </td>
|
||||
<td>
|
||||
{% if ps.name != '' %}
|
||||
<a class="small"
|
||||
href="/rowers/sessions/{{ ps.id }}">{{ ps.name }}</a>
|
||||
{% else %}
|
||||
<a class="small"
|
||||
href="/rowers/sessions/{{ ps.id }}">Unnamed Session</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td> {{ ps.sessionvalue }} </td>
|
||||
<td> {{ ps.sessionunit }} </td>
|
||||
<td>
|
||||
{% if timeperiod and rower %}
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/edit/{{ timeperiod }}/rower/{{ rower.id }}">Edit</a>
|
||||
{% elif timeperiod %}
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/edit/{{ timeperiod }}">Edit</a>
|
||||
{% else %}
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/edit">Edit</a>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/clone">Clone</a>
|
||||
</td>
|
||||
<td>
|
||||
<a class="small" href="/rowers/sessions/{{ ps.id }}/deleteconfirm">Delete</a>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="grid_2">
|
||||
<p>
|
||||
{% if timeperiod and rower %}
|
||||
<a class="button gray small" href="/rowers/sessions/manage{{ timeperiod }}/rower/{{ rower.id }}">Manage Sessions</a>
|
||||
<a class="button gray small" href="/rowers/sessions/manage/{{ timeperiod }}/rower/{{ rower.id }}">Manage Sessions</a>
|
||||
{% elif timeperiod %}
|
||||
<a class="button gray small" href="/rowers/sessions/manage/{{ timeperiod }}">Manage Sessions</a>
|
||||
{% else %}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
{% extends "base.html" %}
|
||||
{% block title %}About us{% endblock title %}
|
||||
{% block content %}
|
||||
<h2>Pro Membership</h2>
|
||||
|
||||
<div class="grid_6 alpha">
|
||||
<h2>Pro Membership</h2>
|
||||
|
||||
<p>Donations are welcome to keep this web site going. To help cover the hosting
|
||||
costs, I have created a <q>Pro</q> membership option (for only 15 EURO per year). Once I process your
|
||||
@@ -27,7 +27,7 @@ You will be taken to the secure PayPal payment site.
|
||||
</div>
|
||||
|
||||
<div class="grid_6 omega">
|
||||
<h3>Recurring Payment</h2>
|
||||
<h2>Recurring Payment</h2>
|
||||
<p>You need a Paypal account for this</p>
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
@@ -40,7 +40,7 @@ You will be taken to the secure PayPal payment site.
|
||||
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
||||
</form>
|
||||
|
||||
<h3>One Year Subscription</h3>
|
||||
<h2>One Year Subscription</h2>
|
||||
<p>Only a credit card needed. Will not automatically renew</p>
|
||||
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
||||
<input type="hidden" name="cmd" value="_s-xclick">
|
||||
@@ -49,7 +49,7 @@ You will be taken to the secure PayPal payment site.
|
||||
<img alt="" border="0" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif" width="1" height="1">
|
||||
</form>
|
||||
|
||||
<h3>Payment Processing</h3>
|
||||
<h2>Payment Processing</h2>
|
||||
<p>After you do the payment, we will manually change your membership to
|
||||
"Pro". Depending on our availability, this may take some time
|
||||
(typically one working day). Don't hesitate to contact us
|
||||
|
||||
@@ -382,6 +382,7 @@ urlpatterns = [
|
||||
url(r'^videos', TemplateView.as_view(template_name='videos.html'),name='videos'),
|
||||
url(r'^analysis', TemplateView.as_view(template_name='analysis.html'),name='analysis'),
|
||||
url(r'^promembership', TemplateView.as_view(template_name='promembership.html'),name='promembership'),
|
||||
url(r'^planmembership', TemplateView.as_view(template_name='planmembership.html'),name='planmembership'),
|
||||
url(r'^paypaltest', TemplateView.as_view(template_name='paypaltest.html'),name='paypaltest'),
|
||||
url(r'^legal', TemplateView.as_view(template_name='legal.html'),name='legal'),
|
||||
url(r'^register$',views.rower_register_view),
|
||||
@@ -397,11 +398,25 @@ urlpatterns = [
|
||||
url(r'^test\_callback',views.rower_process_testcallback),
|
||||
url(r'^workout/(?P<id>\d+)/test\_strokedata$',views.strokedataform),
|
||||
url(r'^sessions/create$',views.plannedsession_create_view),
|
||||
url(r'^sessions/create/rower/(?P<rowerid>\d+)$',
|
||||
views.plannedsession_create_view),
|
||||
url(
|
||||
r'^sessions/create/(?P<timeperiod>[\w\ ]+.*)/rower/(?P<rowerid>\d+)$',
|
||||
views.plannedsession_create_view),
|
||||
url(r'^sessions/create/(?P<timeperiod>[\w\ ]+.*)$',
|
||||
views.plannedsession_create_view),
|
||||
|
||||
url(r'^sessions/(?P<id>\d+)/edit$',views.plannedsession_edit_view),
|
||||
url(r'^sessions/(?P<id>\d+)/edit/(?P<timeperiod>[\w\ ]+.*)/rower/(?P<rowerid>\d+)$',views.plannedsession_edit_view),
|
||||
url(r'^sessions/(?P<id>\d+)/edit/(?P<timeperiod>[\w\ ]+.*)$',views.plannedsession_edit_view),
|
||||
|
||||
url(r'^sessions/(?P<id>\d+)/clone$',views.plannedsession_clone_view),
|
||||
url(r'^sessions/(?P<id>\d+)/clone/(?P<timeperiod>[\w\ ]+.*)/rower/(?P<rowerid>\d+)$',views.plannedsession_clone_view),
|
||||
url(r'^sessions/(?P<id>\d+)/clone/(?P<timeperiod>[\w\ ]+.*)$',views.plannedsession_clone_view),
|
||||
|
||||
url(r'^sessions/(?P<id>\d+)$',views.plannedsession_view),
|
||||
url(r'^sessions/(?P<id>\d+)/deleteconfirm$',views.plannedsession_deleteconfirm_view),
|
||||
url(r'^sessions/(?P<id>\d+)/delete$',views.plannedsession_delete_view),
|
||||
|
||||
url(r'^sessions/manage/session/(?P<initialsession>\d+)$',
|
||||
views.plannedsessions_manage_view),
|
||||
url(r'^sessions/manage/rower/(?P<rowerid>\d+)/session/(?P<initialsession>\d+)$',
|
||||
|
||||
109
rowers/views.py
109
rowers/views.py
@@ -11710,11 +11710,19 @@ def agegrouprecordview(request,sex='male',weightcategory='hwt',
|
||||
})
|
||||
|
||||
# Individual user creates training for himself
|
||||
@user_passes_test(hasplannedsessions,login_url="/rowers/promembership/",
|
||||
@user_passes_test(hasplannedsessions,login_url="/rowers/planmembership/",
|
||||
redirect_field_name=None)
|
||||
def plannedsession_create_view(request):
|
||||
def plannedsession_create_view(request,timeperiod='today',rowerid=0):
|
||||
|
||||
r = getrower(request.user)
|
||||
if rowerid==0:
|
||||
r = getrower(request.user)
|
||||
else:
|
||||
try:
|
||||
r = Rower.objects.get(id=rowerid)
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("This rower doesn't exist")
|
||||
if not checkaccessuser(request.user,r):
|
||||
raise Http404("You don't have access to this plan")
|
||||
|
||||
if request.method == 'POST':
|
||||
sessioncreateform = PlannedSessionForm(request.POST)
|
||||
@@ -11724,6 +11732,7 @@ def plannedsession_create_view(request):
|
||||
enddate = cd['enddate']
|
||||
sessiontype = cd['sessiontype']
|
||||
sessionmode = cd['sessionmode']
|
||||
criterium = cd['criterium']
|
||||
sessionvalue = cd['sessionvalue']
|
||||
sessionunit = cd['sessionunit']
|
||||
comment = cd['comment']
|
||||
@@ -11743,6 +11752,7 @@ def plannedsession_create_view(request):
|
||||
sessionvalue=sessionvalue,
|
||||
sessionunit=sessionunit,
|
||||
comment=comment,
|
||||
criterium=criterium,
|
||||
manager=request.user)
|
||||
|
||||
ps.save()
|
||||
@@ -11754,13 +11764,15 @@ def plannedsession_create_view(request):
|
||||
else:
|
||||
sessioncreateform = PlannedSessionForm()
|
||||
|
||||
sps = get_sessions(r)
|
||||
startdate,enddate = get_dates_timeperiod(timeperiod)
|
||||
sps = get_sessions(r,startdate=startdate,enddate=enddate)
|
||||
|
||||
return render(request,'plannedsessioncreate.html',
|
||||
{
|
||||
'teams':get_my_teams(request.user),
|
||||
'form':sessioncreateform,
|
||||
'plannedsessions':sps,
|
||||
'rower':r,
|
||||
})
|
||||
|
||||
@login_required()
|
||||
@@ -11909,12 +11921,22 @@ def plannedsessions_manage_view(request,timeperiod='today',rowerid=0,
|
||||
})
|
||||
|
||||
|
||||
# Edit an existing planned session
|
||||
@user_passes_test(hasplannedsessions,login_url="/rowers/promembership/",
|
||||
# Clone an existing planned session
|
||||
@user_passes_test(hasplannedsessions,login_url="/rowers/planmembership/",
|
||||
redirect_field_name=None)
|
||||
def plannedsession_edit_view(request,id=0):
|
||||
def plannedsession_clone_view(request,id=0,rowerid=0,
|
||||
timeperiod='today'):
|
||||
if rowerid==0:
|
||||
r = getrower(request.user)
|
||||
else:
|
||||
try:
|
||||
r = Rower.objects.get(id=rowerid)
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("This rower doesn't exist")
|
||||
if not checkaccessuser(request.user,r):
|
||||
raise Http404("You don't have access to this plan")
|
||||
|
||||
r = getrower(request.user)
|
||||
startdate,enddate = get_dates_timeperiod(timeperiod)
|
||||
|
||||
try:
|
||||
ps = PlannedSession.objects.get(id=id)
|
||||
@@ -11922,26 +11944,65 @@ def plannedsession_edit_view(request,id=0):
|
||||
raise Http404("Planned Session does not exist")
|
||||
|
||||
if ps.manager != request.user:
|
||||
raise Http404("You are not allowed to delete this planned session")
|
||||
raise Http404("You are not allowed to clone this planned session")
|
||||
|
||||
ps.pk = None
|
||||
|
||||
ps.startdate = timezone.now()
|
||||
ps.enddate = timezone.now()
|
||||
ps.name += ' (copy)'
|
||||
|
||||
ps.save()
|
||||
|
||||
add_rower_session(r,ps)
|
||||
|
||||
url = reverse(plannedsession_edit_view,
|
||||
kwargs = {
|
||||
'id':ps.id,
|
||||
'timeperiod':timeperiod,
|
||||
'rowerid':r.id,
|
||||
}
|
||||
)
|
||||
|
||||
return HttpResponseRedirect(url)
|
||||
|
||||
|
||||
# Edit an existing planned session
|
||||
@user_passes_test(hasplannedsessions,login_url="/rowers/planmembership/",
|
||||
redirect_field_name=None)
|
||||
def plannedsession_edit_view(request,id=0,timeperiod='today',rowerid=0):
|
||||
|
||||
if rowerid==0:
|
||||
r = getrower(request.user)
|
||||
else:
|
||||
try:
|
||||
r = Rower.objects.get(id=rowerid)
|
||||
except Rower.DoesNotExist:
|
||||
raise Http404("This rower doesn't exist")
|
||||
if not checkaccessuser(request.user,r):
|
||||
raise Http404("You don't have access to this plan")
|
||||
|
||||
startdate,enddate = get_dates_timeperiod(timeperiod)
|
||||
|
||||
|
||||
try:
|
||||
ps = PlannedSession.objects.get(id=id)
|
||||
except PlannedSession.DoesNotExist:
|
||||
raise Http404("Planned Session does not exist")
|
||||
|
||||
if ps.manager != request.user:
|
||||
raise Http404("You are not allowed to edit this planned session")
|
||||
|
||||
if request.method == 'POST':
|
||||
sessioncreateform = PlannedSessionForm(request.POST,instance=ps)
|
||||
if sessioncreateform.is_valid():
|
||||
cd = sessioncreateform.cleaned_data
|
||||
startdate = cd['startdate']
|
||||
enddate = cd['enddate']
|
||||
sessiontype = cd['sessiontype']
|
||||
sessionmode = cd['sessionmode']
|
||||
sessionvalue = cd['sessionvalue']
|
||||
sessionunit = cd['sessionunit']
|
||||
|
||||
if sessionunit == 'min':
|
||||
sessionmode = 'time'
|
||||
elif sessionunit in ['km','m']:
|
||||
sessionmode = 'distance'
|
||||
if cd['sessionunit'] == 'min':
|
||||
cd['sessionmode'] = 'time'
|
||||
elif cd['sessionunit'] in ['km','m']:
|
||||
cd['sessionmode'] = 'distance'
|
||||
|
||||
comment = cd['comment']
|
||||
name = cd['name']
|
||||
|
||||
res,message = update_plannedsession(ps,cd)
|
||||
|
||||
@@ -11953,12 +12014,14 @@ def plannedsession_edit_view(request,id=0):
|
||||
url = reverse(plannedsession_edit_view,
|
||||
kwargs={
|
||||
'id':int(ps.id),
|
||||
'timeperiod':timeperiod,
|
||||
'rowerid':r.id,
|
||||
})
|
||||
return HttpResponseRedirect(url)
|
||||
else:
|
||||
sessioncreateform = PlannedSessionForm(instance=ps)
|
||||
|
||||
sps = get_sessions(r)
|
||||
sps = get_sessions(r,startdate=startdate,enddate=enddate)
|
||||
|
||||
return render(request,'plannedsessionedit.html',
|
||||
{
|
||||
@@ -11966,6 +12029,8 @@ def plannedsession_edit_view(request,id=0):
|
||||
'form':sessioncreateform,
|
||||
'plannedsessions':sps,
|
||||
'thesession':ps,
|
||||
'rower':r,
|
||||
'timeperiod':timeperiod,
|
||||
})
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user