]> git.openstreetmap.org Git - osqa.git/blob - forum/middleware/cancel.py
Merge pull request #11 from udacity/make_faq_settings_translatable
[osqa.git] / forum / middleware / cancel.py
1 from django.http import HttpResponseRedirect
2 from forum.forms import get_next_url
3 import logging
4 class CancelActionMiddleware(object):
5     def process_view(self, request, view_func, view_args, view_kwargs):
6         if 'cancel' in request.REQUEST:
7             #todo use session messages for the anonymous users
8             try:
9                 msg = getattr(view_func,'CANCEL_MESSAGE')
10             except AttributeError:
11                 msg = 'action canceled'
12             request.user.message_set.create(message=msg)
13             return HttpResponseRedirect(get_next_url(request))
14         else:
15             return None