diff --git a/mayan/apps/common/settings.py b/mayan/apps/common/settings.py index c6079f42bf..2187fd1db5 100644 --- a/mayan/apps/common/settings.py +++ b/mayan/apps/common/settings.py @@ -355,7 +355,20 @@ setting_django_login_redirect_url = namespace.add_setting( 'for example. This setting also accepts named URL patterns which ' 'can be used to reduce configuration duplication since you don\'t ' 'have to define the URL in two places (settings and URLconf).' - ), + ) +) +setting_django_logout_redirect_url = namespace.add_setting( + global_name='LOGOUT_REDIRECT_URL', + default=settings.LOGOUT_REDIRECT_URL, + help_text=_( + 'Default: None. The URL where requests are redirected after a user ' + 'logs out using LogoutView (if the view doesn\'t get a next_page ' + 'argument). If None, no redirect will be performed and the logout ' + 'view will be rendered. This setting also accepts named URL ' + 'patterns which can be used to reduce configuration duplication ' + 'since you don\'t have to define the URL in two places (settings ' + 'and URLconf).' + ) ) setting_django_static_url = namespace.add_setting( global_name='STATIC_URL', diff --git a/mayan/apps/smart_settings/literals.py b/mayan/apps/smart_settings/literals.py index b8ba171ff9..fdd1cd9d10 100644 --- a/mayan/apps/smart_settings/literals.py +++ b/mayan/apps/smart_settings/literals.py @@ -1,5 +1,14 @@ from __future__ import unicode_literals +DJANGO_SETTINGS_DEFAULTS = { + # Default in YAML format + 'DEBUG': 'false', + 'LOGIN_URL': 'authentication:login_view', + 'LOGIN_REDIRECT_URL': 'common:home', + 'LOGOUT_REDIRECT_URL': 'authentication:login_view', +} + + DJANGO_SETTINGS_LIST = ( 'ALLOWED_HOSTS', 'APPEND_SLASH', 'AUTH_PASSWORD_VALIDATORS', 'DATA_UPLOAD_MAX_MEMORY_SIZE', 'DATABASES', 'DEBUG', 'DEFAULT_FROM_EMAIL', @@ -7,6 +16,6 @@ DJANGO_SETTINGS_LIST = ( 'EMAIL_HOST_PASSWORD', 'EMAIL_HOST_USER', 'EMAIL_PORT', 'EMAIL_TIMEOUT', 'EMAIL_USE_SSL', 'EMAIL_USE_TLS', 'FILE_UPLOAD_MAX_MEMORY_SIZE', 'HOME_VIEW', 'INSTALLED_APPS', 'INTERNAL_IPS', 'LANGUAGES', - 'LANGUAGE_CODE', 'LOGIN_REDIRECT_URL', 'LOGIN_URL', 'STATIC_URL', - 'STATICFILES_STORAGE', 'TIME_ZONE', 'WSGI_APPLICATION', + 'LANGUAGE_CODE', 'LOGIN_REDIRECT_URL', 'LOGIN_URL', 'LOGOUT_REDIRECT_URL', + 'STATIC_URL', 'STATICFILES_STORAGE', 'TIME_ZONE', 'WSGI_APPLICATION' ) diff --git a/mayan/settings/base.py b/mayan/settings/base.py index 9192d17cd2..bcc8bd887b 100644 --- a/mayan/settings/base.py +++ b/mayan/settings/base.py @@ -16,7 +16,9 @@ import sys from django.utils.translation import ugettext_lazy as _ -from mayan.apps.smart_settings.literals import DJANGO_SETTINGS_LIST +from mayan.apps.smart_settings.literals import ( + DJANGO_SETTINGS_DEFAULTS, DJANGO_SETTINGS_LIST +) from mayan.apps.smart_settings.utils import ( get_environment_variables, read_configuration_file, yaml_loads ) @@ -50,7 +52,9 @@ else: # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = yaml_loads(os.environ.get('MAYAN_DEBUG', 'false')) +DEBUG = yaml_loads( + os.environ.get('MAYAN_DEBUG', DJANGO_SETTINGS_DEFAULTS.get('DEBUG')) +) ALLOWED_HOSTS = ['127.0.0.1', 'localhost', '[::1]'] @@ -249,10 +253,21 @@ TEST_RUNNER = 'mayan.apps.common.tests.runner.MayanTestRunner' # --------- Django ------------------- LOGIN_URL = yaml_loads( - os.environ.get('MAYAN_LOGIN_URL', 'authentication:login_view') + os.environ.get( + 'MAYAN_LOGIN_URL', DJANGO_SETTINGS_DEFAULTS.get('LOGIN_URL') + ) ) LOGIN_REDIRECT_URL = yaml_loads( - os.environ.get('MAYAN_LOGIN_REDIRECT_URL', 'common:root') + os.environ.get( + 'MAYAN_LOGIN_REDIRECT_URL', + DJANGO_SETTINGS_DEFAULTS.get('LOGIN_REDIRECT_URL') + ) +) +LOGOUT_REDIRECT_URL = yaml_loads( + os.environ.get( + 'MAYAN_LOGOUT_REDIRECT_URL', + DJANGO_SETTINGS_DEFAULTS.get('LOGOUT_REDIRECT_URL') + ) ) INTERNAL_IPS = ('127.0.0.1',)