X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/1a949f7c97dc2f34c135f5cdf088df2927d3d652..4f6bdf82bd020d966714f8aba451781072a13d47:/forum/middleware/request_utils.py diff --git a/forum/middleware/request_utils.py b/forum/middleware/request_utils.py index a96f372..40736bf 100644 --- a/forum/middleware/request_utils.py +++ b/forum/middleware/request_utils.py @@ -1,3 +1,6 @@ +from forum.settings import MAINTAINANCE_MODE, APP_LOGO, APP_TITLE + +from forum.http_responses import HttpResponseServiceUnavailable class RequestUtils(object): def __init__(self): @@ -23,6 +26,16 @@ class RequestUtils(object): return int(pagesize) def process_request(self, request): + if MAINTAINANCE_MODE.value is not None and isinstance(MAINTAINANCE_MODE.value.get('allow_ips', None), list): + ip = request.META['REMOTE_ADDR'] + + if not ip in MAINTAINANCE_MODE.value['allow_ips']: + return HttpResponseServiceUnavailable(MAINTAINANCE_MODE.value.get('message', '')) + + if request.session.get('redirect_POST_data', None): + request.POST = request.session.pop('redirect_POST_data') + request.META['REQUEST_METHOD'] = "POST" + self.request = request request.utils = self return None \ No newline at end of file