Commit b4ce2e6f80e1c391ff1963e679102cc1bfd67e3d

Authored by Claude Paroz
1 parent 664a8ae3

Prevented deprecation warning when sending moderation email

Showing 1 changed file with 6 additions and 3 deletions
... ... @@ -56,6 +56,7 @@ class.
56 56
57 57 import datetime
58 58
  59 +from django import VERSION
59 60 from django.conf import settings
60 61 from django.core.mail import send_mail
61 62 from django.db.models.base import ModelBase
... ... @@ -245,11 +246,13 @@ class CommentModerator(object):
245 246 return
246 247 recipient_list = [manager_tuple[1] for manager_tuple in settings.MANAGERS]
247 248 t = loader.get_template('comments/comment_notification_email.txt')
248   - c = Context({'comment': comment,
249   - 'content_object': content_object})
  249 + c = {
  250 + 'comment': comment,
  251 + 'content_object': content_object,
  252 + }
250 253 subject = '[%s] New comment posted on "%s"' % (get_current_site(request).name,
251 254 content_object)
252   - message = t.render(c)
  255 + message = t.render(Context(c) if VERSION < (1, 8) else c)
253 256 send_mail(subject, message, settings.DEFAULT_FROM_EMAIL, recipient_list, fail_silently=True)
254 257
255 258
... ...
Please register or login to post a comment