Mercurial > public > sg101
diff messages/views.py @ 803:b3eeaefc39a8
Private message refactoring: add options page.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Sun, 31 Aug 2014 12:46:21 -0500 |
parents | dbc389a409f5 |
children | 95b3d59913ad |
line wrap: on
line diff
--- a/messages/views.py Sat Aug 30 19:11:32 2014 -0500 +++ b/messages/views.py Sun Aug 31 12:46:21 2014 -0500 @@ -112,6 +112,28 @@ @login_required +def options(request): + """ + This view handles the displaying and changing of private message options. + + """ + if request.method == 'POST': + options = Options.objects.for_user(request.user) + form = OptionsForm(request.POST, instance=options, prefix='opts') + if form.is_valid(): + form.save() + django_messages.success(request, 'Options saved.') + else: + options = Options.objects.for_user(request.user) + form = OptionsForm(instance=options, prefix='opts') + + return render(request, 'messages/options.html', { + 'tab': 'options', + 'form': form, + }) + + +@login_required def compose_to(request, receiver): """ This function displays the base tabbed private messages view, @@ -158,29 +180,6 @@ return HttpResponse(result, content_type='application/json') -def options(request): - """ - This view handles the displaying and changing of private message options. - - """ - if not request.user.is_authenticated(): - return HttpResponseForbidden() - - if request.method == "POST": - options = Options.objects.for_user(request.user) - form = OptionsForm(request.POST, instance=options, prefix='opts') - if form.is_valid(): - form.save() - django_messages.success(request, 'Options saved.') - else: - options = Options.objects.for_user(request.user) - form = OptionsForm(instance=options, prefix='opts') - - return render(request, 'messages/options_tab.html', { - 'form': form, - }) - - def compose(request, receiver=None): """ Process or prepare the compose form to create a new private message.