diff --git a/rowers/models.py b/rowers/models.py
index cc8883d9..af9aa4ff 100644
--- a/rowers/models.py
+++ b/rowers/models.py
@@ -855,6 +855,22 @@ class RowerForm(ModelForm):
if an>=max:
raise forms.ValidationError("AN should be lower than Max")
+# A comment by a user on a training
+class WorkoutComment(models.Model):
+ created = models.DateField(default=timezone.now)
+ comment = models.TextField(max_length=300)
+ read = models.BooleanField(default=False)
+ user = models.ForeignKey(User)
+ workout = models.ForeignKey(Workout)
+
+class WorkoutCommentForm(ModelForm):
+ class Meta:
+ model = WorkoutComment
+ fields = ['comment']
+ widgets = {
+ 'comment': forms.Textarea,
+ }
+
# An announcement that goes to the right of the workouts list
# optionally sends a tweet to our twitter account
class SiteAnnouncement(models.Model):
diff --git a/rowers/templates/workout_comments.html b/rowers/templates/workout_comments.html
new file mode 100644
index 00000000..d87b5cf2
--- /dev/null
+++ b/rowers/templates/workout_comments.html
@@ -0,0 +1,192 @@
+{% extends "base.html" %}
+{% load staticfiles %}
+{% load rowerfilters %}
+{% load tz %}
+
+{% block title %}Change Workout {% endblock %}
+
+{% block content %}
+
+
+ {% if form.errors %}
+
+ Please correct the error{{ form.errors|pluralize }} below.
+
+ {% endif %}
+
+
Comments {{ workout.name }}
+
+{% localtime on %}
+
+{% endlocaltime %}
+
+
+
+
Images linked to this workout
+
+
+
+
+
+
+
+
+
Generating images takes roughly 1 second per minute
+ of your workout's duration. Please reload after a minute or so.
+
+
+ {% if graphs1 %}
+
+ {% for graph in graphs1 %}
+ {% if forloop.counter == 1 %}
+
+
+ 
+
+ {% elif forloop.counter == 3 %}
+
+
+ 
+
+
+ {% else %}
+
+
+ 
+
+ {% endif %}
+ {% endfor %}
+
+
+ {% for graph in graphs2 %}
+ {% if forloop.counter == 1 %}
+
+
+ 
+
+ {% elif forloop.counter == 3 %}
+
+
+ 
+
+
+ {% else %}
+
+
+ 
+
+ {% endif %}
+ {% endfor %}
+
+
+
+
+ {% else %}
+
No graphs found
+ {% endif %}
+
+
+
+
+
+
Workout Summary
+
+
+
+{{ workout.summary }}
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ gmscript |safe }}
+
+
+
+ {{ gmdiv|safe }}
+
+
+
+{% endblock %}
diff --git a/rowers/templates/workout_form.html b/rowers/templates/workout_form.html
index 356a245a..e47136e8 100644
--- a/rowers/templates/workout_form.html
+++ b/rowers/templates/workout_form.html
@@ -14,7 +14,7 @@
{% endif %}
-
Edit Workout Data
+
Edit Workout {{ workout.name }}
diff --git a/rowers/templates/workout_view.html b/rowers/templates/workout_view.html
index 2bee8359..3bbb4d4b 100644
--- a/rowers/templates/workout_view.html
+++ b/rowers/templates/workout_view.html
@@ -8,7 +8,7 @@
-
Workout Data
+
{{ workout.name }}
| Rower: | {{ first_name }} {{ last_name }} |
diff --git a/rowers/urls.py b/rowers/urls.py
index 37ec074b..e54bbac2 100644
--- a/rowers/urls.py
+++ b/rowers/urls.py
@@ -148,6 +148,7 @@ urlpatterns = [
url(r'^workout/(?P\d+)/export/c/(?P\w+.*)$',views.workout_export_view),
url(r'^workout/(?P\d+)/export/s/(?P\w+.*)$',views.workout_export_view),
url(r'^workout/(?P\d+)/export$',views.workout_export_view),
+ url(r'^workout/(?P\d+)/comment$',views.workout_comment_view),
url(r'^workout/(\d+)/emailtcx$',views.workout_tcxemail_view),
url(r'^workout/(\d+)/emailcsv$',views.workout_csvemail_view),
url(r'^workout/compare/(\d+)/$',views.workout_comparison_list),
diff --git a/rowers/views.py b/rowers/views.py
index 9250f6c0..43cfea8b 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -32,7 +32,8 @@ from rowers.models import Workout, User, Rower, WorkoutForm,FavoriteChart
from rowers.models import (
RowerPowerForm,RowerForm,GraphImage,AdvancedWorkoutForm,
RowerPowerZonesForm,AccountRowerForm,UserForm,StrokeData,
- Team,TeamForm,TeamInviteForm,TeamInvite,TeamRequest
+ Team,TeamForm,TeamInviteForm,TeamInvite,TeamRequest,
+ WorkoutComment,WorkoutCommentForm
)
from rowers.models import FavoriteForm,BaseFavoriteFormSet,SiteAnnouncement
from django.forms.formsets import formset_factory
@@ -3314,6 +3315,26 @@ def workout_export_view(request,id=0, message="", successmessage=""):
'successmessage':successmessage,
})
+# list of comments to a workout
+@login_required()
+def workout_comment_view(request,id=0):
+ try:
+ w = Workout.objects.get(id=id)
+ except Workout.DoesNotExist:
+ raise Http404("Workout doesn't exist")
+
+ if w.privacy == 'private' and w.user.user != request.user:
+ return HttpResponseForbidden("Permission error")
+
+ # ok we're permitted
+ comments = WorkoutComment.objects.filter(workout=w)
+
+ return render(request,
+ 'workout_comments.html',
+ {'workout':w,
+ 'comments':comments,
+ })
+
# The basic edit page
@login_required()
def workout_edit_view(request,id=0,message="",successmessage=""):