1 from django.http import HttpResponseRedirect
2 from forum.forms import get_next_url
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
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))