diff messages/views.py @ 813:eca0c17ff9c8

Private message refactor: reports should email admins. Added tests for reporting messages and ensuring emails are sent when messages are sent (when user options allow it).
author Brian Neal <bgneal@gmail.com>
date Mon, 08 Sep 2014 20:50:37 -0500
parents 42436d674ba8
children cf486a8e8b43
line wrap: on
line diff
--- a/messages/views.py	Sun Sep 07 16:53:05 2014 -0500
+++ b/messages/views.py	Mon Sep 08 20:50:37 2014 -0500
@@ -16,11 +16,17 @@
 from messages.forms import OptionsForm, ComposeForm, ReportForm
 from messages.utils import reply_subject
 from messages import MSG_BOX_LIMIT
-from core.functions import quote_message
+from core.functions import email_admins, quote_message
 
 
 MSGS_PER_PAGE = 20      # message pagination value
 
+REPORT_SUBJECT = 'A user has flagged a private message'
+REPORT_MSG = """Hello,
+
+A user has flagged a private message for review.
+"""
+
 
 def _quota_check(box_name, count, request):
     """
@@ -328,6 +334,7 @@
             flag = form.save(commit=False)
             flag.message = msg
             flag.save()
+            email_admins(REPORT_SUBJECT, REPORT_MSG)
             django_messages.success(request,
                     'Message reported. An admin will be notified. Thank you.')
             return redirect('messages-inbox')