diff --git a/rowers/models.py b/rowers/models.py index 2b6a1531..b618a24c 100644 --- a/rowers/models.py +++ b/rowers/models.py @@ -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 diff --git a/rowers/views.py b/rowers/views.py index cad0bbd4..af9d658c 100644 --- a/rowers/views.py +++ b/rowers/views.py @@ -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: {comment}'.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, diff --git a/rowsandall_app/settings.py b/rowsandall_app/settings.py index 610abcb8..168952ac 100644 --- a/rowsandall_app/settings.py +++ b/rowsandall_app/settings.py @@ -74,6 +74,7 @@ AUTHENTICATION_BACKENDS = ( MIDDLEWARE_CLASSES = [ # 'django.middleware.cache.UpdateCacheMiddleware', 'django.middleware.common.CommonMiddleware', + 'django.middleware.common.BrokenLinkEmailsMiddleware', 'django.middleware.gzip.GZipMiddleware', # 'htmlmin.middleware.HtmlMinifyMiddleware', 'htmlmin.middleware.MarkRequestMiddleware', diff --git a/templates/basebase.html b/templates/basebase.html index b49d47da..91c432aa 100644 --- a/templates/basebase.html +++ b/templates/basebase.html @@ -161,7 +161,7 @@ {% else %}

{% endif %} - {{ message }} + {{ message|safe }}

{% endfor %} {% endif %}