2018-09-07 15:12:39 -05:00
|
|
|
from django.conf import settings
|
|
|
|
from django.core.exceptions import MiddlewareNotUsed
|
|
|
|
from django.http import HttpResponseForbidden
|
2021-05-17 03:51:24 -05:00
|
|
|
from django.utils.translation import gettext as _
|
2018-09-07 15:12:39 -05:00
|
|
|
|
|
|
|
|
|
|
|
def readonly_middleware(get_response):
|
|
|
|
|
|
|
|
if not settings.UMAP_READONLY:
|
|
|
|
raise MiddlewareNotUsed
|
|
|
|
|
|
|
|
def middleware(request):
|
|
|
|
if request.method not in ['GET', 'OPTIONS']:
|
2018-09-08 09:49:25 -05:00
|
|
|
return HttpResponseForbidden(_('Site is readonly for maintenance'))
|
2018-09-07 15:12:39 -05:00
|
|
|
|
|
|
|
return get_response(request)
|
|
|
|
|
|
|
|
return middleware
|