Show More
@@ -19,10 +19,18 b'' | |||||
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
20 |
|
20 | |||
21 |
|
21 | |||
|
22 | from rhodecode.admin.navigation import NavigationRegistry | |||
22 | from rhodecode.config.routing import ADMIN_PREFIX |
|
23 | from rhodecode.config.routing import ADMIN_PREFIX | |
|
24 | from rhodecode.lib.utils2 import str2bool | |||
23 |
|
25 | |||
24 |
|
26 | |||
25 | def includeme(config): |
|
27 | def includeme(config): | |
|
28 | settings = config.get_settings() | |||
|
29 | ||||
|
30 | # Create admin navigation registry and add it to the pyramid registry. | |||
|
31 | labs_active = str2bool(settings.get('labs_settings_active', False)) | |||
|
32 | navigation_registry = NavigationRegistry(labs_active=labs_active) | |||
|
33 | config.registry.registerUtility(navigation_registry) | |||
26 |
|
34 | |||
27 | config.add_route( |
|
35 | config.add_route( | |
28 | name='admin_settings_open_source', |
|
36 | name='admin_settings_open_source', |
@@ -21,13 +21,12 b'' | |||||
21 |
|
21 | |||
22 | import logging |
|
22 | import logging | |
23 | import collections |
|
23 | import collections | |
|
24 | ||||
24 | from pylons import url |
|
25 | from pylons import url | |
25 | from pylons.i18n.translation import lazy_ugettext |
|
26 | from pylons.i18n.translation import lazy_ugettext | |
26 | from zope.interface import implementer |
|
27 | from zope.interface import implementer | |
27 |
|
28 | |||
28 | import rhodecode |
|
|||
29 | from rhodecode.admin.interfaces import IAdminNavigationRegistry |
|
29 | from rhodecode.admin.interfaces import IAdminNavigationRegistry | |
30 | from rhodecode.lib.utils2 import str2bool |
|
|||
31 |
|
30 | |||
32 |
|
31 | |||
33 | log = logging.getLogger(__name__) |
|
32 | log = logging.getLogger(__name__) | |
@@ -83,17 +82,16 b' class NavigationRegistry(object):' | |||||
83 | # 'admin_settings_supervisor'), |
|
82 | # 'admin_settings_supervisor'), | |
84 | ] |
|
83 | ] | |
85 |
|
84 | |||
86 | def __init__(self): |
|
85 | _labs_entry = NavEntry('labs', lazy_ugettext('Labs'), | |
|
86 | 'admin_settings_labs') | |||
|
87 | ||||
|
88 | def __init__(self, labs_active=False): | |||
87 | self._registered_entries = collections.OrderedDict([ |
|
89 | self._registered_entries = collections.OrderedDict([ | |
88 | (item.key, item) for item in self.__class__._base_entries |
|
90 | (item.key, item) for item in self.__class__._base_entries | |
89 | ]) |
|
91 | ]) | |
90 |
|
92 | |||
91 | # Add the labs entry when it's activated. |
|
|||
92 | labs_active = str2bool( |
|
|||
93 | rhodecode.CONFIG.get('labs_settings_active', 'false')) |
|
|||
94 | if labs_active: |
|
93 | if labs_active: | |
95 | self.add_entry( |
|
94 | self.add_entry(self._labs_entry) | |
96 | NavEntry('labs', lazy_ugettext('Labs'), 'admin_settings_labs')) |
|
|||
97 |
|
95 | |||
98 | def add_entry(self, entry): |
|
96 | def add_entry(self, entry): | |
99 | self._registered_entries[entry.key] = entry |
|
97 | self._registered_entries[entry.key] = entry | |
@@ -103,4 +101,18 b' class NavigationRegistry(object):' | |||||
103 | for i in self._registered_entries.values()] |
|
101 | for i in self._registered_entries.values()] | |
104 | return navlist |
|
102 | return navlist | |
105 |
|
103 | |||
106 | navigation = NavigationRegistry() |
|
104 | ||
|
105 | def navigation_registry(request): | |||
|
106 | """ | |||
|
107 | Helper that returns the admin navigation registry. | |||
|
108 | """ | |||
|
109 | pyramid_registry = request.registry | |||
|
110 | nav_registry = pyramid_registry.queryUtility(IAdminNavigationRegistry) | |||
|
111 | return nav_registry | |||
|
112 | ||||
|
113 | ||||
|
114 | def navigation_list(request): | |||
|
115 | """ | |||
|
116 | Helper that returns the admin navigation as list of NavListEntry objects. | |||
|
117 | """ | |||
|
118 | return navigation_registry(request).get_navlist(request) |
@@ -24,10 +24,11 b' import logging' | |||||
24 | from pylons import tmpl_context as c |
|
24 | from pylons import tmpl_context as c | |
25 | from pyramid.view import view_config |
|
25 | from pyramid.view import view_config | |
26 |
|
26 | |||
27 | from rhodecode.controllers.admin.settings import navigation |
|
|||
28 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator |
|
27 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator | |
29 | from rhodecode.lib.utils import read_opensource_licenses |
|
28 | from rhodecode.lib.utils import read_opensource_licenses | |
30 |
|
29 | |||
|
30 | from .navigation import navigation_list | |||
|
31 | ||||
31 |
|
32 | |||
32 | log = logging.getLogger(__name__) |
|
33 | log = logging.getLogger(__name__) | |
33 |
|
34 | |||
@@ -47,7 +48,7 b' class AdminSettingsView(object):' | |||||
47 | renderer='rhodecode:templates/admin/settings/settings.html') |
|
48 | renderer='rhodecode:templates/admin/settings/settings.html') | |
48 | def open_source_licenses(self): |
|
49 | def open_source_licenses(self): | |
49 | c.active = 'open_source' |
|
50 | c.active = 'open_source' | |
50 |
c.navlist = navigation |
|
51 | c.navlist = navigation_list(self.request) | |
51 | c.opensource_licenses = collections.OrderedDict( |
|
52 | c.opensource_licenses = collections.OrderedDict( | |
52 | sorted(read_opensource_licenses().items(), key=lambda t: t[0])) |
|
53 | sorted(read_opensource_licenses().items(), key=lambda t: t[0])) | |
53 |
|
54 |
@@ -37,7 +37,7 b' from pylons.i18n.translation import _, l' | |||||
37 | from webob.exc import HTTPBadRequest |
|
37 | from webob.exc import HTTPBadRequest | |
38 |
|
38 | |||
39 | import rhodecode |
|
39 | import rhodecode | |
40 | from rhodecode.admin.navigation import navigation |
|
40 | from rhodecode.admin.navigation import navigation_list | |
41 | from rhodecode.lib import auth |
|
41 | from rhodecode.lib import auth | |
42 | from rhodecode.lib import helpers as h |
|
42 | from rhodecode.lib import helpers as h | |
43 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator |
|
43 | from rhodecode.lib.auth import LoginRequired, HasPermissionAllDecorator | |
@@ -80,7 +80,7 b' class SettingsController(BaseController)' | |||||
80 | super(SettingsController, self).__before__() |
|
80 | super(SettingsController, self).__before__() | |
81 | c.labs_active = str2bool( |
|
81 | c.labs_active = str2bool( | |
82 | rhodecode.CONFIG.get('labs_settings_active', 'false')) |
|
82 | rhodecode.CONFIG.get('labs_settings_active', 'false')) | |
83 |
c.navlist = navigation |
|
83 | c.navlist = navigation_list(request) | |
84 |
|
84 | |||
85 | def _get_hg_ui_settings(self): |
|
85 | def _get_hg_ui_settings(self): | |
86 | ret = RhodeCodeUi.query().all() |
|
86 | ret = RhodeCodeUi.query().all() |
General Comments 0
You need to be logged in to leave comments.
Login now