1 from django.http import HttpResponseRedirect
2 from forum.forms import get_next_url
4 from django.contrib import messages
6 class CancelActionMiddleware(object):
7 def process_view(self, request, view_func, view_args, view_kwargs):
8 if 'cancel' in request.REQUEST:
9 #todo use session messages for the anonymous users
11 msg = getattr(view_func,'CANCEL_MESSAGE')
12 except AttributeError:
13 msg = 'action canceled'
14 messages.info(request, msg)
15 return HttpResponseRedirect(get_next_url(request))