diff --git a/HISTORY.rst b/HISTORY.rst index 45e8aebce9..e02a44dd5d 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -15,6 +15,7 @@ * Remove catch all exception handling for the check in and check out views. * Improve checkouts tests code reducing redundant code. +* Change how the HOME_VIEW setting is defined. 3.1.11 (2019-04-XX) =================== diff --git a/docs/releases/3.2.rst b/docs/releases/3.2.rst index 06537d4888..cf3066eff8 100644 --- a/docs/releases/3.2.rst +++ b/docs/releases/3.2.rst @@ -27,6 +27,10 @@ Other changes * Fix multiple tag selection wizard step. * Split document app models into separate modules. * Split workflow views into separate modules. +* Change how the HOME_VIEW setting is defined + +HOME_VIEW is now COMMON_HOME_VIEW. + Removals -------- diff --git a/mayan/apps/authentication/views.py b/mayan/apps/authentication/views.py index 8907285954..acc3e15c5e 100644 --- a/mayan/apps/authentication/views.py +++ b/mayan/apps/authentication/views.py @@ -16,7 +16,9 @@ from django.utils.translation import ugettext_lazy as _ from stronghold.decorators import public import mayan -from mayan.apps.common.settings import setting_project_title, setting_project_url +from mayan.apps.common.settings import ( + setting_home_view, setting_project_title, setting_project_url +) from .forms import EmailAuthenticationForm, UsernameAuthenticationForm from .settings import setting_login_method, setting_maximum_session_length @@ -84,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 9cec91e637..3222fd755e 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): @@ -397,7 +398,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 612707460d..77a5b25be8 100644 --- a/mayan/apps/common/settings.py +++ b/mayan/apps/common/settings.py @@ -9,6 +9,9 @@ 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 +27,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, @@ -234,14 +245,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 316f817a38..e65c39a336 100644 --- a/mayan/apps/common/views.py +++ b/mayan/apps/common/views.py @@ -32,6 +32,7 @@ from .generics import ( # NOQA from .icons import icon_setup from .menus import menu_tools, menu_setup from .permissions_runtime import permission_error_log_view +from .settings import setting_home_view from .utils import check_version @@ -243,7 +244,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 28ca20d6c0..0fbe64fc34 100644 --- a/mayan/settings/base.py +++ b/mayan/settings/base.py @@ -250,7 +250,6 @@ TEST_RUNNER = 'mayan.apps.common.tests.runner.MayanTestRunner' # --------- Django ------------------- -HOME_VIEW = env('MAYAN_HOME_VIEW', default='common:home') LOGIN_URL = env('MAYAN_LOGIN_URL', default='authentication:login_view') LOGIN_REDIRECT_URL = env('MAYAN_LOGIN_REDIRECT_URL', default='common:root') INTERNAL_IPS = ('127.0.0.1',)