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):
|
2023-11-23 11:04:23 -06:00
|
|
|
if request.method not in ["GET", "OPTIONS"]:
|
|
|
|
return HttpResponseForbidden(_("Site is readonly for maintenance"))
|
2018-09-07 15:12:39 -05:00
|
|
|
|
|
|
|
return get_response(request)
|
|
|
|
|
|
|
|
return middleware
|