notifications for comments
This commit is contained in:
@@ -327,7 +327,15 @@ class BaseFavoriteFormSet(BaseFormSet):
|
||||
def checkworkoutuser(user,workout):
|
||||
try:
|
||||
r = Rower.objects.get(user=user)
|
||||
return workout.user == r
|
||||
teams = workout.team.all()
|
||||
if workout.user == r:
|
||||
return True
|
||||
elif teams:
|
||||
for team in teams:
|
||||
if user == team.manager:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
except Rower.DoesNotExist:
|
||||
return False
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import time
|
||||
import timestring
|
||||
import zipfile
|
||||
import bleach
|
||||
import operator
|
||||
import warnings
|
||||
import urllib
|
||||
@@ -4625,10 +4626,23 @@ def workout_comment_view(request,id=0):
|
||||
if form.is_valid():
|
||||
cd = form.cleaned_data
|
||||
comment = cd['comment']
|
||||
comment = bleach.clean(comment)
|
||||
notification = cd['notification']
|
||||
c = WorkoutComment(workout=w,user=request.user,comment=comment,
|
||||
notification=notification)
|
||||
c.save()
|
||||
url = reverse(workout_comment_view,
|
||||
kwargs={
|
||||
'id':id
|
||||
})
|
||||
message = '{name} says: <a href="{url}">{comment}</a>'.format(
|
||||
name = request.user.first_name,
|
||||
comment = comment,
|
||||
url = url,
|
||||
)
|
||||
if request.user != r.user:
|
||||
a_messages.info(r.user,message)
|
||||
|
||||
if settings.DEBUG and request.user != r.user:
|
||||
res = handle_sendemailnewcomment.delay(r.user.first_name,
|
||||
r.user.last_name,
|
||||
@@ -4649,6 +4663,7 @@ def workout_comment_view(request,id=0):
|
||||
|
||||
commenters = {oc.user for oc in comments if oc.notification}
|
||||
for u in commenters:
|
||||
a_messages.info(u,message)
|
||||
if settings.DEBUG and u != request.user and u != r.user:
|
||||
res = handle_sendemailnewresponse.delay(u.first_name,
|
||||
u.last_name,
|
||||
|
||||
Reference in New Issue
Block a user