Move setting namespace initalization code to the class itself. Add method to invalidate all setting caches. Use smart setting cache invalidation for properly test advanced search pagination.
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from importlib import import_module
|
||||
import logging
|
||||
|
||||
from django.apps import apps
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
|
||||
from common import MayanAppConfig, menu_setup, menu_object
|
||||
@@ -14,8 +12,6 @@ from .classes import Namespace, Setting
|
||||
from .links import link_namespace_detail, link_namespace_list
|
||||
from .widgets import setting_widget
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SmartSettingsApp(MayanAppConfig):
|
||||
app_namespace = 'settings'
|
||||
@@ -26,6 +22,8 @@ class SmartSettingsApp(MayanAppConfig):
|
||||
def ready(self):
|
||||
super(SmartSettingsApp, self).ready()
|
||||
|
||||
Namespace.initialize()
|
||||
|
||||
SourceColumn(
|
||||
source=Namespace, label=_('Setting count'),
|
||||
func=lambda context: len(context['object'].settings)
|
||||
@@ -48,13 +46,3 @@ class SmartSettingsApp(MayanAppConfig):
|
||||
links=(link_namespace_detail,), sources=(Namespace,)
|
||||
)
|
||||
menu_setup.bind_links(links=(link_namespace_list,))
|
||||
|
||||
for app in apps.get_app_configs():
|
||||
try:
|
||||
import_module('{}.settings'.format(app.name))
|
||||
except ImportError:
|
||||
logger.debug('App %s has not settings.py file', app.name)
|
||||
else:
|
||||
logger.debug(
|
||||
'Imported settings.py file for app %s', app.name
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user