comparison 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
comparison
equal deleted inserted replaced
801:6bbd1473d48e 802:dbc389a409f5
95 'outbox_pct': pct_used, 95 'outbox_pct': pct_used,
96 }) 96 })
97 97
98 98
99 @login_required 99 @login_required
100 def trash(request):
101
102 msg_list = Message.objects.trash(request.user)
103
104 page = _get_page(request, msg_list)
105
106 return render(request, 'messages/trash.html', {
107 'tab': 'trash',
108 'page': page,
109 'inbox_pct': None,
110 'outbox_pct': None,
111 })
112
113
114 @login_required
100 def compose_to(request, receiver): 115 def compose_to(request, receiver):
101 """ 116 """
102 This function displays the base tabbed private messages view, 117 This function displays the base tabbed private messages view,
103 and configures it to display the compose PM tab for the given 118 and configures it to display the compose PM tab for the given
104 receiver. 119 receiver.
108 tab_index = TAB_INDICES['compose'] 123 tab_index = TAB_INDICES['compose']
109 return render(request, 'messages/tabbed_base.html', { 124 return render(request, 'messages/tabbed_base.html', {
110 'tab': tab_index, 125 'tab': tab_index,
111 'receiver': receiver, 126 'receiver': receiver,
112 'unread_count': Message.objects.unread_count(request.user), 127 'unread_count': Message.objects.unread_count(request.user),
113 })
114
115
116 def trash(request):
117 """
118 Returns the trash for the user.
119
120 """
121 if not request.user.is_authenticated():
122 return HttpResponseForbidden()
123
124 msg_list = Message.objects.trash(request.user)
125 paginator = Paginator(msg_list, MSGS_PER_PAGE)
126 try:
127 msgs = paginator.page(_get_page(request))
128 except (EmptyPage, InvalidPage):
129 msgs = paginator.page(paginator.num_pages)
130
131 return render(request, 'messages/trash_tab.html', {
132 'msgs': msgs,
133 'url': reverse('messages-trash'),
134 }) 128 })
135 129
136 130
137 def message(request): 131 def message(request):
138 """ 132 """