added comment functionality
This commit is contained in:
@@ -273,6 +273,35 @@ def handle_sendemail_invite(email,name,code,teamname,manager):
|
||||
|
||||
return 1
|
||||
|
||||
@app.task
|
||||
def handle_sendemailnewcomment(first_name,
|
||||
last_name,
|
||||
email,
|
||||
commenter_first_name,
|
||||
commenter_last_name,
|
||||
comment,workoutname,
|
||||
workoutid):
|
||||
fullemail = first_name+' '+last_name+' <'+email+'>'
|
||||
subject = 'New comment on workout '+workoutname
|
||||
message = 'Dear '+first_name+',\n\n'
|
||||
message += commenter_first_name+' '+commenter_last_name
|
||||
message += ' has written a new comment on your workout '
|
||||
message += workoutname+'\n\n'
|
||||
message += comment
|
||||
message += '\n\n'
|
||||
message += 'You can read the comment here:\n'
|
||||
message += 'https://rowsandall.com/rowers/workout/'+str(workoutid)+'/comment'
|
||||
|
||||
email = EmailMessage(subject, message,
|
||||
'Rowsandall <info@rowsandall.com>',
|
||||
[fullemail])
|
||||
|
||||
|
||||
res = email.send()
|
||||
|
||||
return 1
|
||||
|
||||
|
||||
@app.task
|
||||
def handle_sendemail_request(email,name,code,teamname,requestor,id):
|
||||
fullemail = name+' <'+email+'>'
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
{% block title %}Change Workout {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<script>
|
||||
setTimeout("location.reload(true);",60000);
|
||||
</script>
|
||||
|
||||
<div id="left" class="grid_6 alpha">
|
||||
<div id="summary" class="grid_6 alpha">
|
||||
{% if form.errors %}
|
||||
|
||||
@@ -54,8 +54,14 @@
|
||||
</tr><tr>
|
||||
<th>Public link to this workout</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}">https://rowsandall.com/rowers/workout/{{ workout.id }}</a>
|
||||
</td>
|
||||
</tr><tr>
|
||||
<th>Comments</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}/comment">Comment</a>
|
||||
</td>
|
||||
|
||||
</tr><tr>
|
||||
<th>Public link to interactive chart</th>
|
||||
<td>
|
||||
|
||||
@@ -29,6 +29,12 @@
|
||||
</tr><tr>
|
||||
<th>Weight Category:</th><td>{{ workout.weightcategory }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Comments</th>
|
||||
<td>
|
||||
<a href="/rowers/workout/{{ workout.id }}/comment">Comment</a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h1>Workout Summary</h1>
|
||||
|
||||
@@ -59,7 +59,9 @@ from rest_framework.renderers import JSONRenderer
|
||||
from rest_framework.parsers import JSONParser
|
||||
from rowers.rows import handle_uploaded_file
|
||||
from rowers.tasks import handle_makeplot,handle_otwsetpower,handle_sendemailtcx,handle_sendemailcsv
|
||||
from rowers.tasks import handle_sendemail_unrecognized
|
||||
from rowers.tasks import (
|
||||
handle_sendemail_unrecognized,handle_sendemailnewcomment
|
||||
)
|
||||
|
||||
from scipy.signal import savgol_filter
|
||||
from django.shortcuts import render_to_response
|
||||
@@ -3328,13 +3330,31 @@ def workout_comment_view(request,id=0):
|
||||
return HttpResponseForbidden("Permission error")
|
||||
|
||||
# ok we're permitted
|
||||
if request.method == 'POST':
|
||||
r = w.user
|
||||
form = WorkoutCommentForm(request.POST)
|
||||
if form.is_valid():
|
||||
cd = form.cleaned_data
|
||||
comment = cd['comment']
|
||||
c = WorkoutComment(workout=w,user=request.user,comment=comment)
|
||||
c.save()
|
||||
c.save()
|
||||
if settings.DEBUG:
|
||||
res = handle_sendemailnewcomment.delay(r.user.first_name,
|
||||
r.user.last_name,
|
||||
r.user.email,
|
||||
c.user.first_name,
|
||||
c.user.last_name,
|
||||
comment,w.name,
|
||||
w.id)
|
||||
|
||||
else:
|
||||
res = queuehigh.enqueue(handle_sendemailnewcomment,r.user.first_name,
|
||||
r.user.last_name,
|
||||
r.user.email,
|
||||
r.user.first_name,
|
||||
r.user.last_name,
|
||||
comment,w.name,w.id)
|
||||
|
||||
|
||||
comments = WorkoutComment.objects.filter(workout=w).order_by("created")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user