+{% block main %}
-
-
{{ workout.name }}
-
-
-
-
-
-
-
+{{ workout.name }}
+
+ -
+
+
+
+
+
+
+
+
| Rower: | {{ first_name }} {{ last_name }} |
-
-
+
+
| Name: | {{ workout.name }} |
-
-
+
+
| Date: | {{ workout.date }} |
-
+
| Time: | {{ workout.starttime }} |
-
+
| Distance: | {{ workout.distance }}m |
-
+
| Duration: | {{ workout.duration |durationprint:"%H:%M:%S.%f" }} |
-
+
| Type: | {{ workout.workouttype }} |
-
+
| Weight Category: | {{ workout.weightcategory }} |
-
- {% if user.is_authenticated %}
-
- | Comments |
+
+ {% if user.is_authenticated %}
+
+ | Comments |
Comment ({{ aantalcomments }})
|
-
- {% endif %}
-
-
- Workout Summary
-
-
-
-{{ workout.summary }}
-
-
+
+ {% endif %}
+
+
+
+ Workout Summary
+
+
+ {{ workout.summary }}
+
+
+
+
+
{{ mapdiv|safe }}
{{ mapscript|safe }}
-
-
-
-
-
Images linked to this workout
- {% 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 %}
-
-
-
-
-
- {{ interactiveplot |safe }}
-
-
+
-
+
+ {{ interactiveplot |safe }}
-
-
{{ the_div|safe }}
-
+
+ {% for graph in graphs %}
+
+
+
+
+
+ {% endfor %}
+
{% endblock %}
+
+{% block sidebar %}
+{% include 'menu_workout.html' %}
+{% endblock %}
diff --git a/rowers/views.py b/rowers/views.py
index a8c39f98..774dd29d 100644
--- a/rowers/views.py
+++ b/rowers/views.py
@@ -6596,99 +6596,100 @@ def workout_fusion_list(request,id=0,message='',successmessage='',
except Rower.DoesNotExist:
raise Http404("User has no rower instance")
-# Basic 'EDIT' view of workout
+# Basic view of workout
def workout_view(request,id=0):
request.session['referer'] = absolute(request)['PATH']
- try:
- # check if valid ID exists (workout exists)
- row = Workout.objects.get(id=id)
- comments = WorkoutComment.objects.filter(workout=row)
-
- aantalcomments = len(comments)
-
-
- if row.privacy == 'private':
- raise PermissionDenied("Access denied")
+ if not request.user.is_anonymous():
+ rower = getrower(request.user)
+ else:
+ rower = None
- g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
- for i in g:
- try:
- width,height = Image.open(i.filename).size
- i.width = width
- i.height = height
- i.save()
- except:
- pass
+ try:
+ row = Workout.objects.get(id=id)
+ except Workout.DoesNotExist:
+ raise Http404("Workout doesn't exist")
+
+ comments = WorkoutComment.objects.filter(workout=row)
+
+ aantalcomments = len(comments)
+
+
+ if row.privacy == 'private' and not checkworkoutuser(request.user,row):
+ raise PermissionDenied("Access denied")
+
+ g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
+ for i in g:
+ try:
+ width,height = Image.open(i.filename).size
+ i.width = width
+ i.height = height
+ i.save()
+ except:
+ pass
- r = Rower.objects.get(id=row.user.id)
- u = User.objects.get(id=r.user.id)
- # create interactive plot
- res = interactive_chart(id)
- script = res[0]
- div = res[1]
+ # create interactive plot
+ res = interactive_chart(id)
+ script = res[0]
+ div = res[1]
- # create map
- f1 = row.csvfilename
- u = row.user.user
- r = getrower(u)
- rowdata = rdata(f1)
- hascoordinates = 1
- if rowdata != 0:
- try:
- latitude = rowdata.df[' latitude']
- if not latitude.std():
- hascoordinates = 0
- except KeyError,AttributeError:
+ # create map
+ f1 = row.csvfilename
+ rowdata = rdata(f1)
+ hascoordinates = 1
+ if rowdata != 0:
+ try:
+ latitude = rowdata.df[' latitude']
+ if not latitude.std():
hascoordinates = 0
-
- else:
+ except KeyError,AttributeError:
hascoordinates = 0
+ else:
+ hascoordinates = 0
- if hascoordinates:
- mapscript,mapdiv = leaflet_chart(rowdata.df[' latitude'],
- rowdata.df[' longitude'],
- row.name)
+
+ if hascoordinates:
+ mapscript,mapdiv = leaflet_chart(rowdata.df[' latitude'],
+ rowdata.df[' longitude'],
+ row.name)
- else:
- mapscript = ""
- mapdiv = ""
+ else:
+ mapscript = ""
+ mapdiv = ""
-
- # render page
- if (len(g)<=3):
- return render(request, 'workout_view.html',
- {'workout':row,
- 'graphs1':g[0:3],
- 'last_name':u.last_name,
- 'first_name':u.first_name,
- 'interactiveplot':script,
- 'aantalcomments':aantalcomments,
- 'mapscript':mapscript,
- 'mapdiv':mapdiv,
- 'teams':get_my_teams(request.user),
- 'the_div':div})
- else:
- return render(request, 'workout_view.html',
- {'workout':row,
- 'graphs1':g[0:3],
- 'graphs2':g[3:6],
- 'last_name':u.last_name,
- 'first_name':u.first_name,
- 'teams':get_my_teams(request.user),
- 'aantalcomments':aantalcomments,
- 'mapscript':mapscript,
- 'mapdiv':mapdiv,
- 'interactiveplot':script,
- 'the_div':div})
+ breadcrumbs = [
+ {
+ 'url':'/rowers/list-workouts',
+ 'name':'Workouts'
+ },
+ {
+ 'url':reverse(workout_view,kwargs={'id':id}),
+ 'name': id,
+ }
+
+ ]
-
- except Workout.DoesNotExist:
- raise Http404("Workout doesn't exist")
+ u = row.user.user
+
+ return render(request, 'workout_view.html',
+ {'workout':row,
+ 'rower':rower,
+ 'breadcrumbs':breadcrumbs,
+ 'active':'nav-workouts',
+ 'graphs':g,
+ 'last_name':u.last_name,
+ 'first_name':u.first_name,
+ 'interactiveplot':script,
+ 'aantalcomments':aantalcomments,
+ 'mapscript':mapscript,
+ 'mapdiv':mapdiv,
+ 'teams':get_my_teams(request.user),
+ 'the_div':div})
+
# Resets stroke data to raw data (pace)
@user_passes_test(ispromember,login_url="/",redirect_field_name=None)