diff messages/views.py @ 802:dbc389a409f5

Work in progress: rework private messages. Add trash view.
author Brian Neal <bgneal@gmail.com>
date Sat, 30 Aug 2014 19:11:32 -0500
parents 6bbd1473d48e
children b3eeaefc39a8
line wrap: on
line diff
--- a/messages/views.py	Sat Aug 30 17:25:38 2014 -0500
+++ b/messages/views.py	Sat Aug 30 19:11:32 2014 -0500
@@ -97,6 +97,21 @@
 
 
 @login_required
+def trash(request):
+
+    msg_list = Message.objects.trash(request.user)
+
+    page = _get_page(request, msg_list)
+
+    return render(request, 'messages/trash.html', {
+        'tab': 'trash',
+        'page': page,
+        'inbox_pct': None,
+        'outbox_pct': None,
+        })
+
+
+@login_required
 def compose_to(request, receiver):
     """
     This function displays the base tabbed private messages view,
@@ -113,27 +128,6 @@
         })
 
 
-def trash(request):
-    """
-    Returns the trash for the user.
-
-    """
-    if not request.user.is_authenticated():
-        return HttpResponseForbidden()
-
-    msg_list = Message.objects.trash(request.user)
-    paginator = Paginator(msg_list, MSGS_PER_PAGE)
-    try:
-        msgs = paginator.page(_get_page(request))
-    except (EmptyPage, InvalidPage):
-        msgs = paginator.page(paginator.num_pages)
-
-    return render(request, 'messages/trash_tab.html', {
-        'msgs': msgs,
-        'url': reverse('messages-trash'),
-        })
-
-
 def message(request):
     """
     This view function retrieves a message and returns it as a JSON object.