diff --git a/HISTORY.rst b/HISTORY.rst index 23977f1943..57345715cd 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -155,6 +155,9 @@ version of the python-gnupg package (0.4.3). - Set sensible default path for binaries by detecting the operating system. +- The HOME_VIEW setting is not a Django setting but a setting + from the common app. The HOME_VIEW has been moved to the + COMMON namespace and renamed to COMMON_HOME_VIEW. 3.1.9 (2018-11-01) ================== diff --git a/mayan/apps/authentication/views.py b/mayan/apps/authentication/views.py index 9ff0146275..6a657b7350 100644 --- a/mayan/apps/authentication/views.py +++ b/mayan/apps/authentication/views.py @@ -17,7 +17,7 @@ from stronghold.decorators import public import mayan from mayan.apps.common.settings import ( - setting_project_title, setting_project_url + setting_home_view, setting_project_title, setting_project_url ) from .forms import EmailAuthenticationForm, UsernameAuthenticationForm @@ -86,7 +86,7 @@ def password_change_view(request): 'Changing the password is not allowed for this account.' ) ) - return HttpResponseRedirect(reverse(settings.HOME_VIEW)) + return HttpResponseRedirect(reverse(setting_home_view.view)) return password_change( request, extra_context=extra_context, diff --git a/mayan/apps/common/classes.py b/mayan/apps/common/classes.py index 576aa286d3..340653c6e2 100644 --- a/mayan/apps/common/classes.py +++ b/mayan/apps/common/classes.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import hashlib from django.apps import apps -from django.conf import settings from django.db import models from django.template import loader from django.template.response import TemplateResponse @@ -11,6 +10,8 @@ from django.urls import reverse from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.translation import ugettext +from .settings import setting_home_view + @python_2_unicode_compatible class Collection(object): @@ -385,7 +386,7 @@ class Template(object): def render(self, request): context = { - 'home_view': settings.HOME_VIEW, + 'home_view': setting_home_view.value, } result = TemplateResponse( request=request, diff --git a/mayan/apps/common/literals.py b/mayan/apps/common/literals.py index a8826f1d51..7513a2d33c 100644 --- a/mayan/apps/common/literals.py +++ b/mayan/apps/common/literals.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals from django.utils.translation import ugettext_lazy as _ +DEFAULT_COMMON_HOME_VIEW = 'common:home' DELETE_STALE_UPLOADS_INTERVAL = 60 * 10 # 10 minutes DJANGO_SQLITE_BACKEND = 'django.db.backends.sqlite3' MAYAN_PYPI_NAME = 'mayan-edms' diff --git a/mayan/apps/common/settings.py b/mayan/apps/common/settings.py index 35a8900d3b..87243bc927 100644 --- a/mayan/apps/common/settings.py +++ b/mayan/apps/common/settings.py @@ -9,6 +9,8 @@ from django.utils.translation import ugettext_lazy as _ import mayan from mayan.apps.smart_settings import Namespace +from .literals import DEFAULT_COMMON_HOME_VIEW + namespace = Namespace(name='common', label=_('Common')) setting_auto_logging = namespace.add_setting( @@ -24,6 +26,14 @@ settings_db_sync_task_delay = namespace.add_setting( 'propagate.' ) ) +setting_home_view = namespace.add_setting( + global_name='COMMON_HOME_VIEW', + default=DEFAULT_COMMON_HOME_VIEW, help_text=_( + 'Name of the view attached to the branch anchor in the main menu. ' + 'This is also the view to which users will be redirected after ' + 'log in.' + ), +) setting_paginate_by = namespace.add_setting( global_name='COMMON_PAGINATE_BY', default=40, @@ -276,14 +286,6 @@ setting_django_file_upload_max_memory_size = namespace.add_setting( 'DATA_UPLOAD_MAX_MEMORY_SIZE.' ), ) -# Not really a Django setting, but since it is flat and defined in setting.py -# We need to put it here. -setting_home_view = namespace.add_setting( - global_name='HOME_VIEW', - default=settings.HOME_VIEW, help_text=_( - 'Name of the view attached to the branch anchor in the main menu.' - ), -) setting_django_installed_apps = namespace.add_setting( global_name='INSTALLED_APPS', default=settings.INSTALLED_APPS, diff --git a/mayan/apps/common/views.py b/mayan/apps/common/views.py index 3b72ac917e..89aede0302 100644 --- a/mayan/apps/common/views.py +++ b/mayan/apps/common/views.py @@ -31,6 +31,7 @@ from .generics import ( # NOQA from .icons import icon_setup from .menus import menu_setup, menu_tools from .permissions_runtime import permission_error_log_view +from .settings import setting_home_view from .utils import check_version @@ -242,7 +243,7 @@ class PackagesLicensesView(SimpleView): class RootView(SimpleView): - extra_context = {'home_view': settings.HOME_VIEW} + extra_context = {'home_view': setting_home_view.value} template_name = 'appearance/root.html' diff --git a/mayan/settings/base.py b/mayan/settings/base.py index f95767c83a..f5bd311660 100644 --- a/mayan/settings/base.py +++ b/mayan/settings/base.py @@ -242,7 +242,6 @@ TEST_RUNNER = 'mayan.apps.common.tests.runner.MayanTestRunner' # --------- Django ------------------- -HOME_VIEW = yaml_loads(os.environ.get('MAYAN_HOME_VIEW', 'common:home')) LOGIN_URL = yaml_loads( os.environ.get('MAYAN_LOGIN_URL', 'authentication:login_view') )