##// END OF EJS Templates
admin: simplify usage of admin prefix on admin routes.
marcink -
r1542:366f5b0d default
parent child Browse files
Show More
@@ -1,77 +1,85 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2016-2017 RhodeCode GmbH
4 4 #
5 5 # This program is free software: you can redistribute it and/or modify
6 6 # it under the terms of the GNU Affero General Public License, version 3
7 7 # (only), as published by the Free Software Foundation.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU Affero General Public License
15 15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16 16 #
17 17 # This program is dual-licensed. If you wish to learn more about the
18 18 # RhodeCode Enterprise Edition, including its added features, Support services,
19 19 # and proprietary license terms, please see https://rhodecode.com/licenses/
20 20
21 21
22 22 from rhodecode.apps.admin.navigation import NavigationRegistry
23 23 from rhodecode.config.routing import ADMIN_PREFIX
24 24 from rhodecode.lib.utils2 import str2bool
25 25
26 26
27 def admin_routes(config):
28 """
29 Admin prefixed routes
30 """
31
32 config.add_route(
33 name='admin_settings_open_source',
34 pattern='/settings/open_source')
35 config.add_route(
36 name='admin_settings_vcs_svn_generate_cfg',
37 pattern='/settings/vcs/svn_generate_cfg')
38
39 config.add_route(
40 name='admin_settings_system',
41 pattern='/settings/system')
42 config.add_route(
43 name='admin_settings_system_update',
44 pattern='/settings/system/updates')
45
46 config.add_route(
47 name='admin_settings_sessions',
48 pattern='/settings/sessions')
49 config.add_route(
50 name='admin_settings_sessions_cleanup',
51 pattern='/settings/sessions/cleanup')
52
53 # users admin
54 config.add_route(
55 name='users',
56 pattern='/users')
57
58 config.add_route(
59 name='users_data',
60 pattern='/users_data')
61
62 # user auth tokens
63 config.add_route(
64 name='edit_user_auth_tokens',
65 pattern='/users/{user_id:\d+}/edit/auth_tokens')
66 config.add_route(
67 name='edit_user_auth_tokens_add',
68 pattern='/users/{user_id:\d+}/edit/auth_tokens/new')
69 config.add_route(
70 name='edit_user_auth_tokens_delete',
71 pattern='/users/{user_id:\d+}/edit/auth_tokens/delete')
72
73
27 74 def includeme(config):
28 75 settings = config.get_settings()
29 76
30 77 # Create admin navigation registry and add it to the pyramid registry.
31 78 labs_active = str2bool(settings.get('labs_settings_active', False))
32 79 navigation_registry = NavigationRegistry(labs_active=labs_active)
33 80 config.registry.registerUtility(navigation_registry)
34 81
35 config.add_route(
36 name='admin_settings_open_source',
37 pattern=ADMIN_PREFIX + '/settings/open_source')
38 config.add_route(
39 name='admin_settings_vcs_svn_generate_cfg',
40 pattern=ADMIN_PREFIX + '/settings/vcs/svn_generate_cfg')
41
42 config.add_route(
43 name='admin_settings_system',
44 pattern=ADMIN_PREFIX + '/settings/system')
45 config.add_route(
46 name='admin_settings_system_update',
47 pattern=ADMIN_PREFIX + '/settings/system/updates')
48
49 config.add_route(
50 name='admin_settings_sessions',
51 pattern=ADMIN_PREFIX + '/settings/sessions')
52 config.add_route(
53 name='admin_settings_sessions_cleanup',
54 pattern=ADMIN_PREFIX + '/settings/sessions/cleanup')
55
56 # users admin
57 config.add_route(
58 name='users',
59 pattern=ADMIN_PREFIX + '/users')
60
61 config.add_route(
62 name='users_data',
63 pattern=ADMIN_PREFIX + '/users_data')
64
65 # user auth tokens
66 config.add_route(
67 name='edit_user_auth_tokens',
68 pattern=ADMIN_PREFIX + '/users/{user_id:\d+}/edit/auth_tokens')
69 config.add_route(
70 name='edit_user_auth_tokens_add',
71 pattern=ADMIN_PREFIX + '/users/{user_id:\d+}/edit/auth_tokens/new')
72 config.add_route(
73 name='edit_user_auth_tokens_delete',
74 pattern=ADMIN_PREFIX + '/users/{user_id:\d+}/edit/auth_tokens/delete')
82 config.include(admin_routes, route_prefix=ADMIN_PREFIX)
75 83
76 84 # Scan module for configuration decorators.
77 85 config.scan()
General Comments 0
You need to be logged in to leave comments. Login now