diff messages/views.py @ 812:42436d674ba8

Private message refactor: add unit tests for message cycle.
author Brian Neal <bgneal@gmail.com>
date Sun, 07 Sep 2014 16:53:05 -0500
parents 4a4fa174a0ec
children eca0c17ff9c8
line wrap: on
line diff
--- a/messages/views.py	Sun Sep 07 13:12:19 2014 -0500
+++ b/messages/views.py	Sun Sep 07 16:53:05 2014 -0500
@@ -110,6 +110,7 @@
         if form.is_valid():
             form.save()
             django_messages.success(request, 'Options saved.')
+            return redirect('messages-options')
     else:
         options = Options.objects.for_user(request.user)
         form = OptionsForm(instance=options, prefix='opts')
@@ -155,6 +156,8 @@
     the user is a recipient of the message, a reply can be composed and sent.
 
     """
+    msg = get_object_or_404(Message.objects.select_related(), pk=msg_id)
+
     if request.method == 'POST':
         form = ComposeForm(request.user, request.POST)
         if form.is_valid():
@@ -162,7 +165,6 @@
             django_messages.success(request, 'Reply sent.')
             return redirect('messages-inbox')
     else:
-        msg = get_object_or_404(Message.objects.select_related(), pk=msg_id)
         if msg.sender != request.user and msg.receiver != request.user:
             django_messages.error(request,
                     "You don't have permission to read that message.")