Instead of inserting the path of the apps into the Python app, the apps are now referenced by their full import path. This solves name clashes with external or native Python libraries. Example: Mayan statistics app vs. Python new statistics library. Every app reference is now prepended with 'mayan.apps'. Existing config.yml files need to be updated manually. Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
from __future__ import unicode_literals
|
|
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from mayan.apps.common import (
|
|
MayanAppConfig, menu_sidebar, menu_setup, menu_object
|
|
)
|
|
from mayan.apps.navigation import SourceColumn
|
|
|
|
from .classes import Namespace, Setting
|
|
from .links import (
|
|
link_namespace_detail, link_namespace_list, link_namespace_root_list,
|
|
link_setting_edit
|
|
)
|
|
from .widgets import setting_widget
|
|
|
|
|
|
class SmartSettingsApp(MayanAppConfig):
|
|
app_namespace = 'settings'
|
|
app_url = 'settings'
|
|
has_tests = True
|
|
name = 'mayan.apps.smart_settings'
|
|
verbose_name = _('Smart settings')
|
|
|
|
def ready(self):
|
|
super(SmartSettingsApp, self).ready()
|
|
|
|
Namespace.initialize()
|
|
|
|
SourceColumn(
|
|
source=Namespace, label=_('Setting count'),
|
|
func=lambda context: len(context['object'].settings)
|
|
)
|
|
SourceColumn(
|
|
source=Setting, label=_('Name'),
|
|
func=lambda context: setting_widget(context['object'])
|
|
)
|
|
SourceColumn(
|
|
source=Setting, label=_('Value'), attribute='serialized_value'
|
|
)
|
|
SourceColumn(
|
|
source=Setting, label=_('Overrided by environment variable?'),
|
|
func=lambda context: _('Yes') if context['object'].environment_variable else _('No')
|
|
)
|
|
|
|
menu_object.bind_links(
|
|
links=(link_namespace_detail,), sources=(Namespace,)
|
|
)
|
|
menu_object.bind_links(
|
|
links=(link_setting_edit,), sources=(Setting,)
|
|
)
|
|
menu_sidebar.bind_links(
|
|
links=(link_namespace_root_list,), sources=(
|
|
Namespace, Setting, 'settings:namespace_list',
|
|
)
|
|
)
|
|
menu_setup.bind_links(links=(link_namespace_list,))
|
|
|
|
Setting.save_last_known_good()
|