Private
Public Access
1
0

added comment functionality

This commit is contained in:
Sander Roosendaal
2017-02-17 16:35:34 +01:00
parent 53f51c456f
commit cee6179416
5 changed files with 65 additions and 8 deletions

View File

@@ -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")