Mercurial > public > sg101
comparison messages/views.py @ 1133:62cfdddd584a
Convert private messages to V3_DESIGN.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Tue, 04 Oct 2016 20:26:34 -0500 |
parents | 79a71b9d0a2a |
children |
comparison
equal
deleted
inserted
replaced
1132:1407af5472e4 | 1133:62cfdddd584a |
---|---|
72 return render(request, 'messages/inbox.html', { | 72 return render(request, 'messages/inbox.html', { |
73 'tab': 'inbox', | 73 'tab': 'inbox', |
74 'page': page, | 74 'page': page, |
75 'inbox_pct': pct_used, | 75 'inbox_pct': pct_used, |
76 'outbox_pct': None, | 76 'outbox_pct': None, |
77 'V3_DESIGN': True, | |
77 }) | 78 }) |
78 | 79 |
79 | 80 |
80 @login_required | 81 @login_required |
81 def outbox(request): | 82 def outbox(request): |
89 return render(request, 'messages/outbox.html', { | 90 return render(request, 'messages/outbox.html', { |
90 'tab': 'outbox', | 91 'tab': 'outbox', |
91 'page': page, | 92 'page': page, |
92 'inbox_pct': None, | 93 'inbox_pct': None, |
93 'outbox_pct': pct_used, | 94 'outbox_pct': pct_used, |
95 'V3_DESIGN': True, | |
94 }) | 96 }) |
95 | 97 |
96 | 98 |
97 @login_required | 99 @login_required |
98 def trash(request): | 100 def trash(request): |
104 return render(request, 'messages/trash.html', { | 106 return render(request, 'messages/trash.html', { |
105 'tab': 'trash', | 107 'tab': 'trash', |
106 'page': page, | 108 'page': page, |
107 'inbox_pct': None, | 109 'inbox_pct': None, |
108 'outbox_pct': None, | 110 'outbox_pct': None, |
111 'V3_DESIGN': True, | |
109 }) | 112 }) |
110 | 113 |
111 | 114 |
112 @login_required | 115 @login_required |
113 def options(request): | 116 def options(request): |
127 form = OptionsForm(instance=options, prefix='opts') | 130 form = OptionsForm(instance=options, prefix='opts') |
128 | 131 |
129 return render(request, 'messages/options.html', { | 132 return render(request, 'messages/options.html', { |
130 'tab': 'options', | 133 'tab': 'options', |
131 'form': form, | 134 'form': form, |
135 'V3_DESIGN': True, | |
132 }) | 136 }) |
133 | 137 |
134 | 138 |
135 @login_required | 139 @login_required |
136 def compose(request): | 140 def compose(request): |
155 _quota_check('outbox', Message.objects.outbox(request.user).count(), request) | 159 _quota_check('outbox', Message.objects.outbox(request.user).count(), request) |
156 | 160 |
157 return render(request, 'messages/compose.html', { | 161 return render(request, 'messages/compose.html', { |
158 'tab': 'compose', | 162 'tab': 'compose', |
159 'compose_form': compose_form, | 163 'compose_form': compose_form, |
164 'V3_DESIGN': True, | |
160 }) | 165 }) |
161 | 166 |
162 | 167 |
163 @login_required | 168 @login_required |
164 def view(request, msg_id): | 169 def view(request, msg_id): |
176 django_messages.success(request, 'Reply sent.') | 181 django_messages.success(request, 'Reply sent.') |
177 return redirect('messages-inbox') | 182 return redirect('messages-inbox') |
178 else: | 183 else: |
179 if msg.sender != request.user and msg.receiver != request.user: | 184 if msg.sender != request.user and msg.receiver != request.user: |
180 django_messages.error(request, | 185 django_messages.error(request, |
181 "You don't have permission to read that message.") | 186 "You don't have permission to read that message.", |
187 extra_tags="alert") | |
188 | |
182 return redirect('messages-inbox') | 189 return redirect('messages-inbox') |
183 | 190 |
184 initial_data = { | 191 initial_data = { |
185 'receiver': msg.sender.username, | 192 'receiver': msg.sender.username, |
186 'subject': reply_subject(msg.subject), | 193 'subject': reply_subject(msg.subject), |
204 | 211 |
205 return render(request, 'messages/view_message.html', { | 212 return render(request, 'messages/view_message.html', { |
206 'msg': msg, | 213 'msg': msg, |
207 'form': form, | 214 'form': form, |
208 'msg_flag': msg_flag, | 215 'msg_flag': msg_flag, |
216 'V3_DESIGN': True, | |
209 }) | 217 }) |
210 | 218 |
211 | 219 |
212 @login_required | 220 @login_required |
213 @require_POST | 221 @require_POST |
276 | 284 |
277 msg = '{} message{} deleted.'.format(count, '' if count == 1 else 's') | 285 msg = '{} message{} deleted.'.format(count, '' if count == 1 else 's') |
278 if count > 0: | 286 if count > 0: |
279 django_messages.success(request, msg) | 287 django_messages.success(request, msg) |
280 else: | 288 else: |
281 django_messages.error(request, msg) | 289 django_messages.error(request, msg, extra_tags="alert") |
282 | 290 |
283 | 291 |
284 def _undelete_pms(user, msg_ids): | 292 def _undelete_pms(user, msg_ids): |
285 """ | 293 """ |
286 Attempts to "undelete" the messages given by the msg_ids list. | 294 Attempts to "undelete" the messages given by the msg_ids list. |
332 """This view is for reporting a PM as spam or abuse. | 340 """This view is for reporting a PM as spam or abuse. |
333 | 341 |
334 """ | 342 """ |
335 msg = get_object_or_404(Message.objects.select_related(), pk=msg_id) | 343 msg = get_object_or_404(Message.objects.select_related(), pk=msg_id) |
336 if msg.receiver != request.user: | 344 if msg.receiver != request.user: |
337 django_messages.error(request, "You can't report this message.") | 345 django_messages.error(request, "You can't report this message.", |
346 extra_tags="alert") | |
338 return redirect('messages-inbox') | 347 return redirect('messages-inbox') |
339 try: | 348 try: |
340 msg.flag | 349 msg.flag |
341 except Flag.DoesNotExist: | 350 except Flag.DoesNotExist: |
342 pass | 351 pass |
343 else: | 352 else: |
344 django_messages.error(request, "This message has already been reported.") | 353 django_messages.error(request, "This message has already been reported.", |
354 extra_tags="alert") | |
345 return redirect('messages-inbox') | 355 return redirect('messages-inbox') |
346 | 356 |
347 if request.method == 'POST': | 357 if request.method == 'POST': |
348 form = ReportForm(request.POST) | 358 form = ReportForm(request.POST) |
349 if form.is_valid(): | 359 if form.is_valid(): |
358 form = ReportForm() | 368 form = ReportForm() |
359 | 369 |
360 return render(request, 'messages/report_message.html', { | 370 return render(request, 'messages/report_message.html', { |
361 'msg': msg, | 371 'msg': msg, |
362 'form': form, | 372 'form': form, |
373 'V3_DESIGN': True, | |
363 }) | 374 }) |
364 | 375 |
365 | 376 |
366 def _email_pms(request, msg_ids): | 377 def _email_pms(request, msg_ids): |
367 """ | 378 """ |
403 | 414 |
404 msg = '{} message{} sent to email.'.format(count, '' if count == 1 else 's') | 415 msg = '{} message{} sent to email.'.format(count, '' if count == 1 else 's') |
405 if count > 0: | 416 if count > 0: |
406 django_messages.success(request, msg) | 417 django_messages.success(request, msg) |
407 else: | 418 else: |
408 django_messages.error(request, msg) | 419 django_messages.error(request, msg, extra_tags="alert") |