Skip to content
Snippets Groups Projects
Commit c2ed38f4 authored by Nik | Klampfradler's avatar Nik | Klampfradler
Browse files

Merge branch 'issue51' into 'master'

Implement maintenance mode. Closes #51.

Closes #51

See merge request Teckids/BiscuIT/BiscuIT-ng!28
parents c76a13db 4b3cf23a
No related branches found
No related tags found
1 merge request!28Implement maintenance mode. Closes #51.
......@@ -54,6 +54,8 @@ INSTALLED_APPS = [
'fa',
'django_any_js',
'django_tables2',
'django_ipware',
'maintenance_mode',
'menu_generator',
'phonenumber_field',
'debug_toolbar',
......@@ -88,6 +90,7 @@ MIDDLEWARE = [
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'easyaudit.middleware.easyaudit.EasyAuditMiddleware',
'maintenance_mode.middleware.MaintenanceModeMiddleware',
]
ROOT_URLCONF = 'biscuit.core.urls'
......@@ -103,6 +106,7 @@ TEMPLATES = [
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
'maintenance_mode.context_processors.maintenance_mode',
'settings_context_processor.context_processors.settings'
],
},
......@@ -240,4 +244,9 @@ ADMINS = _settings.get('admins', [])
TEMPLATE_VISIBLE_SETTINGS = ['ADMINS']
MAINTENANCE_MODE = _settings.get('maintenance.activate', 'None')
MAINTENANCE_MODE_IGNORE_IP_ADDRESSES = _settings.get('maintenance.ignore_ip_addresses', ())
MAINTENANCE_MODE_GET_CLIENT_IP_ADDRESS = 'ipware.ip.get_ip'
MAINTENANCE_MODE_IGNORE_SUPERUSER = True
_settings.populate_obj(sys.modules[__name__])
......@@ -21,11 +21,13 @@ urlpatterns = [
path('group/<int:id_>', views.group,
{'template': 'full'}, name='group_by_id'),
path('', views.index, name='index'),
path('maintenance-mode/', include('maintenance_mode.urls')),
]
# Custom error pages
handler404 = views.error_handler(404)
handler500 = views.error_handler(500)
handler503 = views.error_handler(503)
# Serve javascript-common if in development
if settings.DEBUG:
......
......@@ -30,6 +30,9 @@ def error_handler(status: int) -> Callable[..., HttpResponse]:
elif status == 500:
context['caption'] = _('Internal server error')
context['message'] = _('An unexpected error has occurred.')
elif status == 503:
context['caption'] = _('Maintenance mode')
context['message'] = _('The maintenance mode is currently enabled. Please try again later.')
return render(request, 'error.html', context, status=status)
......
......@@ -38,6 +38,8 @@ colour = "^0.1.5"
dynaconf = {version = "^2.0", extras = ["yaml", "toml", "ini"]}
django-settings-context-processor = "^0.2"
django-auth-ldap = { version = "^2.0", optional = true }
django-maintenance-mode = "^0.13.3"
django-ipware = "^2.1"
[tool.poetry.extras]
ldap = ["django-auth-ldap"]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment