Private
Public Access
1
0

added number of comments to workout_view

This commit is contained in:
Sander Roosendaal
2017-08-24 18:17:24 +02:00
parent dba006892b
commit 90ada3809f
3 changed files with 15 additions and 2 deletions

View File

@@ -59,7 +59,7 @@
</tr><tr> </tr><tr>
<th>Comments</th> <th>Comments</th>
<td> <td>
<a href="/rowers/workout/{{ workout.id }}/comment">Comment</a> <a href="/rowers/workout/{{ workout.id }}/comment">Comment ({{ aantalcomments }})</a>
</td> </td>
</tr><tr> </tr><tr>

View File

@@ -33,7 +33,7 @@
<tr> <tr>
<th>Comments</th> <th>Comments</th>
<td> <td>
<a href="/rowers/workout/{{ workout.id }}/comment">Comment</a> <a href="/rowers/workout/{{ workout.id }}/comment">Comment ({{ aantalcomments }})</a>
</td> </td>
</tr> </tr>
{% endif %} {% endif %}

View File

@@ -4457,6 +4457,11 @@ def workout_view(request,id=0):
try: try:
# check if valid ID exists (workout exists) # check if valid ID exists (workout exists)
row = Workout.objects.get(id=id) row = Workout.objects.get(id=id)
comments = WorkoutComment.objects.filter(workout=row)
aantalcomments = len(comments)
if row.privacy == 'private': if row.privacy == 'private':
raise Http404("Not allowed to view this workout") raise Http404("Not allowed to view this workout")
@@ -4479,6 +4484,7 @@ def workout_view(request,id=0):
'last_name':u.last_name, 'last_name':u.last_name,
'first_name':u.first_name, 'first_name':u.first_name,
'interactiveplot':script, 'interactiveplot':script,
'aantalcomments':aantalcomments,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'the_div':div}) 'the_div':div})
else: else:
@@ -4489,6 +4495,7 @@ def workout_view(request,id=0):
'last_name':u.last_name, 'last_name':u.last_name,
'first_name':u.first_name, 'first_name':u.first_name,
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'aantalcomments':aantalcomments,
'interactiveplot':script, 'interactiveplot':script,
'the_div':div}) 'the_div':div})
@@ -6200,6 +6207,10 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime") g = GraphImage.objects.filter(workout=row).order_by("-creationdatetime")
# check if user is owner of this workout # check if user is owner of this workout
comments = WorkoutComment.objects.filter(workout=row)
aantalcomments = len(comments)
if (checkworkoutuser(request.user,row)==False): if (checkworkoutuser(request.user,row)==False):
raise Http404("You are not allowed to edit this workout") raise Http404("You are not allowed to edit this workout")
@@ -6245,6 +6256,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
'teams':get_my_teams(request.user), 'teams':get_my_teams(request.user),
'graphs1':g[0:3], 'graphs1':g[0:3],
'mapscript':mapscript, 'mapscript':mapscript,
'aantalcomments':aantalcomments,
'mapdiv':mapdiv, 'mapdiv':mapdiv,
}) })
@@ -6256,6 +6268,7 @@ def workout_edit_view(request,id=0,message="",successmessage=""):
'graphs1':g[0:3], 'graphs1':g[0:3],
'graphs2':g[3:6], 'graphs2':g[3:6],
'mapscript':mapscript, 'mapscript':mapscript,
'aantalcomments':aantalcomments,
'mapdiv':mapdiv, 'mapdiv':mapdiv,
}) })