notifications for comments
This commit is contained in:
@@ -327,7 +327,15 @@ class BaseFavoriteFormSet(BaseFormSet):
|
|||||||
def checkworkoutuser(user,workout):
|
def checkworkoutuser(user,workout):
|
||||||
try:
|
try:
|
||||||
r = Rower.objects.get(user=user)
|
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:
|
except Rower.DoesNotExist:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import time
|
import time
|
||||||
import timestring
|
import timestring
|
||||||
import zipfile
|
import zipfile
|
||||||
|
import bleach
|
||||||
import operator
|
import operator
|
||||||
import warnings
|
import warnings
|
||||||
import urllib
|
import urllib
|
||||||
@@ -4625,10 +4626,23 @@ def workout_comment_view(request,id=0):
|
|||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
cd = form.cleaned_data
|
cd = form.cleaned_data
|
||||||
comment = cd['comment']
|
comment = cd['comment']
|
||||||
|
comment = bleach.clean(comment)
|
||||||
notification = cd['notification']
|
notification = cd['notification']
|
||||||
c = WorkoutComment(workout=w,user=request.user,comment=comment,
|
c = WorkoutComment(workout=w,user=request.user,comment=comment,
|
||||||
notification=notification)
|
notification=notification)
|
||||||
c.save()
|
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:
|
if settings.DEBUG and request.user != r.user:
|
||||||
res = handle_sendemailnewcomment.delay(r.user.first_name,
|
res = handle_sendemailnewcomment.delay(r.user.first_name,
|
||||||
r.user.last_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}
|
commenters = {oc.user for oc in comments if oc.notification}
|
||||||
for u in commenters:
|
for u in commenters:
|
||||||
|
a_messages.info(u,message)
|
||||||
if settings.DEBUG and u != request.user and u != r.user:
|
if settings.DEBUG and u != request.user and u != r.user:
|
||||||
res = handle_sendemailnewresponse.delay(u.first_name,
|
res = handle_sendemailnewresponse.delay(u.first_name,
|
||||||
u.last_name,
|
u.last_name,
|
||||||
|
|||||||
@@ -74,6 +74,7 @@ AUTHENTICATION_BACKENDS = (
|
|||||||
MIDDLEWARE_CLASSES = [
|
MIDDLEWARE_CLASSES = [
|
||||||
# 'django.middleware.cache.UpdateCacheMiddleware',
|
# 'django.middleware.cache.UpdateCacheMiddleware',
|
||||||
'django.middleware.common.CommonMiddleware',
|
'django.middleware.common.CommonMiddleware',
|
||||||
|
'django.middleware.common.BrokenLinkEmailsMiddleware',
|
||||||
'django.middleware.gzip.GZipMiddleware',
|
'django.middleware.gzip.GZipMiddleware',
|
||||||
# 'htmlmin.middleware.HtmlMinifyMiddleware',
|
# 'htmlmin.middleware.HtmlMinifyMiddleware',
|
||||||
'htmlmin.middleware.MarkRequestMiddleware',
|
'htmlmin.middleware.MarkRequestMiddleware',
|
||||||
|
|||||||
@@ -161,7 +161,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<p class="successmessage">
|
<p class="successmessage">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{{ message }}
|
{{ message|safe }}
|
||||||
</p>
|
</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user