]> git.openstreetmap.org Git - osqa.git/blob - forum/middleware/cancel.py
Load jQuery from cdnjs
[osqa.git] / forum / middleware / cancel.py
1 from django.http import HttpResponseRedirect
2 from forum.forms import get_next_url
3 import logging
4 from django.contrib import messages
5
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
10             try:
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))
16         else:
17             return None