]> git.openstreetmap.org Git - osqa.git/blob - forum/middleware/request_utils.py
adding middleware that handles custom pages
[osqa.git] / forum / middleware / request_utils.py
1 from forum.settings import MAINTAINANCE_MODE, APP_LOGO, APP_TITLE
2
3 from forum.http_responses import HttpResponseServiceUnavailable
4
5 class RequestUtils(object):
6     def process_request(self, request):
7         if MAINTAINANCE_MODE.value is not None and isinstance(MAINTAINANCE_MODE.value.get('allow_ips', None), list):
8             ip = request.META['REMOTE_ADDR']
9
10             if not ip in MAINTAINANCE_MODE.value['allow_ips']:
11                 return HttpResponseServiceUnavailable(MAINTAINANCE_MODE.value.get('message', ''))
12
13         if request.session.get('redirect_POST_data', None):
14             request.POST = request.session.pop('redirect_POST_data')
15             request.META['REQUEST_METHOD'] = "POST"
16
17         self.request = request
18         return None