mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-26 09:16:10 -06:00
Rename method & remove login/logout from exempt paths
This commit is contained in:
parent
de4ebaf36b
commit
563d189729
@ -181,19 +181,19 @@ class MaintenanceModeMiddleware:
|
|||||||
|
|
||||||
def __call__(self, request):
|
def __call__(self, request):
|
||||||
if get_config().MAINTENANCE_MODE:
|
if get_config().MAINTENANCE_MODE:
|
||||||
self._prevent_db_write_operations(
|
self._set_session_type(
|
||||||
allow_write=request.path_info.startswith(settings.MAINTENANCE_EXEMPT_PATHS)
|
allow_write=request.path_info.startswith(settings.MAINTENANCE_EXEMPT_PATHS)
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.get_response(request)
|
return self.get_response(request)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _prevent_db_write_operations(allow_write=False):
|
def _set_session_type(allow_write):
|
||||||
"""
|
"""
|
||||||
Prevent any write-related database operations.
|
Prevent any write-related database operations.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
allow_write (bool): Whether to allow write operations.
|
allow_write (bool): If True, write operations will be permitted.
|
||||||
"""
|
"""
|
||||||
with connection.cursor() as cursor:
|
with connection.cursor() as cursor:
|
||||||
mode = 'READ WRITE' if allow_write else 'READ ONLY'
|
mode = 'READ WRITE' if allow_write else 'READ ONLY'
|
||||||
|
@ -480,9 +480,7 @@ AUTH_EXEMPT_PATHS = (
|
|||||||
|
|
||||||
# All URLs starting with a string listed here are exempt from maintenance mode enforcement
|
# All URLs starting with a string listed here are exempt from maintenance mode enforcement
|
||||||
MAINTENANCE_EXEMPT_PATHS = (
|
MAINTENANCE_EXEMPT_PATHS = (
|
||||||
f'/{BASE_PATH}admin/extras/configrevision/',
|
f'/{BASE_PATH}admin/',
|
||||||
f'/{BASE_PATH}login/',
|
|
||||||
f'/{BASE_PATH}logout/',
|
|
||||||
)
|
)
|
||||||
|
|
||||||
SERIALIZATION_MODULES = {
|
SERIALIZATION_MODULES = {
|
||||||
|
Loading…
Reference in New Issue
Block a user