diff options
Diffstat (limited to 'forum/middleware/cancel.py')
-rw-r--r-- | forum/middleware/cancel.py | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/forum/middleware/cancel.py b/forum/middleware/cancel.py new file mode 100644 index 00000000..15a4371d --- /dev/null +++ b/forum/middleware/cancel.py @@ -0,0 +1,15 @@ +from django.http import HttpResponseRedirect +from forum.utils.forms import get_next_url +import logging +class CancelActionMiddleware(object): + def process_view(self, request, view_func, view_args, view_kwargs): + if 'cancel' in request.REQUEST: + #todo use session messages for the anonymous users + try: + msg = getattr(view_func,'CANCEL_MESSAGE') + except AttributeError: + msg = 'action canceled' + request.user.message_set.create(message=msg) + return HttpResponseRedirect(get_next_url(request)) + else: + return None |