Common app: Move HOME_VIEW setting

The HOME_VIEW setting is not a Django setting but a setting from the
common app. Move the HOME_VIEW to the COMMON namespace and rename it
to COMMON_HOME_VIEW.

Signed-off-by: Roberto Rosario <Roberto.Rosario@mayan-edms.com>
This commit is contained in:
Roberto Rosario
2018-12-06 15:58:19 -04:00
parent 0d9bda0ccf
commit 4d84b5f28f
7 changed files with 21 additions and 14 deletions

View File

@@ -155,6 +155,9 @@
version of the python-gnupg package (0.4.3). version of the python-gnupg package (0.4.3).
- Set sensible default path for binaries by detecting - Set sensible default path for binaries by detecting
the operating system. 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) 3.1.9 (2018-11-01)
================== ==================

View File

@@ -17,7 +17,7 @@ from stronghold.decorators import public
import mayan import mayan
from mayan.apps.common.settings import ( 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 from .forms import EmailAuthenticationForm, UsernameAuthenticationForm
@@ -86,7 +86,7 @@ def password_change_view(request):
'Changing the password is not allowed for this account.' '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( return password_change(
request, extra_context=extra_context, request, extra_context=extra_context,

View File

@@ -3,7 +3,6 @@ from __future__ import unicode_literals
import hashlib import hashlib
from django.apps import apps from django.apps import apps
from django.conf import settings
from django.db import models from django.db import models
from django.template import loader from django.template import loader
from django.template.response import TemplateResponse 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.encoding import force_text, python_2_unicode_compatible
from django.utils.translation import ugettext from django.utils.translation import ugettext
from .settings import setting_home_view
@python_2_unicode_compatible @python_2_unicode_compatible
class Collection(object): class Collection(object):
@@ -385,7 +386,7 @@ class Template(object):
def render(self, request): def render(self, request):
context = { context = {
'home_view': settings.HOME_VIEW, 'home_view': setting_home_view.value,
} }
result = TemplateResponse( result = TemplateResponse(
request=request, request=request,

View File

@@ -2,6 +2,7 @@ from __future__ import unicode_literals
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
DEFAULT_COMMON_HOME_VIEW = 'common:home'
DELETE_STALE_UPLOADS_INTERVAL = 60 * 10 # 10 minutes DELETE_STALE_UPLOADS_INTERVAL = 60 * 10 # 10 minutes
DJANGO_SQLITE_BACKEND = 'django.db.backends.sqlite3' DJANGO_SQLITE_BACKEND = 'django.db.backends.sqlite3'
MAYAN_PYPI_NAME = 'mayan-edms' MAYAN_PYPI_NAME = 'mayan-edms'

View File

@@ -9,6 +9,8 @@ from django.utils.translation import ugettext_lazy as _
import mayan import mayan
from mayan.apps.smart_settings import Namespace from mayan.apps.smart_settings import Namespace
from .literals import DEFAULT_COMMON_HOME_VIEW
namespace = Namespace(name='common', label=_('Common')) namespace = Namespace(name='common', label=_('Common'))
setting_auto_logging = namespace.add_setting( setting_auto_logging = namespace.add_setting(
@@ -24,6 +26,14 @@ settings_db_sync_task_delay = namespace.add_setting(
'propagate.' '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( setting_paginate_by = namespace.add_setting(
global_name='COMMON_PAGINATE_BY', global_name='COMMON_PAGINATE_BY',
default=40, default=40,
@@ -276,14 +286,6 @@ setting_django_file_upload_max_memory_size = namespace.add_setting(
'DATA_UPLOAD_MAX_MEMORY_SIZE.' '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( setting_django_installed_apps = namespace.add_setting(
global_name='INSTALLED_APPS', global_name='INSTALLED_APPS',
default=settings.INSTALLED_APPS, default=settings.INSTALLED_APPS,

View File

@@ -31,6 +31,7 @@ from .generics import ( # NOQA
from .icons import icon_setup from .icons import icon_setup
from .menus import menu_setup, menu_tools from .menus import menu_setup, menu_tools
from .permissions_runtime import permission_error_log_view from .permissions_runtime import permission_error_log_view
from .settings import setting_home_view
from .utils import check_version from .utils import check_version
@@ -242,7 +243,7 @@ class PackagesLicensesView(SimpleView):
class RootView(SimpleView): class RootView(SimpleView):
extra_context = {'home_view': settings.HOME_VIEW} extra_context = {'home_view': setting_home_view.value}
template_name = 'appearance/root.html' template_name = 'appearance/root.html'

View File

@@ -242,7 +242,6 @@ TEST_RUNNER = 'mayan.apps.common.tests.runner.MayanTestRunner'
# --------- Django ------------------- # --------- Django -------------------
HOME_VIEW = yaml_loads(os.environ.get('MAYAN_HOME_VIEW', 'common:home'))
LOGIN_URL = yaml_loads( LOGIN_URL = yaml_loads(
os.environ.get('MAYAN_LOGIN_URL', 'authentication:login_view') os.environ.get('MAYAN_LOGIN_URL', 'authentication:login_view')
) )