Show More
@@ -1,40 +1,43 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2016-2016 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.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 | 27 | def includeme(config): |
|
28 | 28 | settings = config.get_settings() |
|
29 | 29 | |
|
30 | 30 | # Create admin navigation registry and add it to the pyramid registry. |
|
31 | 31 | labs_active = str2bool(settings.get('labs_settings_active', False)) |
|
32 | 32 | navigation_registry = NavigationRegistry(labs_active=labs_active) |
|
33 | 33 | config.registry.registerUtility(navigation_registry) |
|
34 | 34 | |
|
35 | 35 | config.add_route( |
|
36 | 36 | name='admin_settings_open_source', |
|
37 | 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') | |
|
38 | 41 | |
|
39 | 42 | # Scan module for configuration decorators. |
|
40 | 43 | config.scan() |
@@ -1,55 +1,82 b'' | |||
|
1 | 1 | # -*- coding: utf-8 -*- |
|
2 | 2 | |
|
3 | 3 | # Copyright (C) 2016-2016 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 | import collections |
|
22 | 22 | import logging |
|
23 | 23 | |
|
24 | 24 | from pylons import tmpl_context as c |
|
25 | 25 | from pyramid.view import view_config |
|
26 | 26 | |
|
27 |
from rhodecode.lib.auth import |
|
|
27 | from rhodecode.lib.auth import ( | |
|
28 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) | |
|
28 | 29 | from rhodecode.lib.utils import read_opensource_licenses |
|
30 | from rhodecode.svn_support.utils import generate_mod_dav_svn_config | |
|
31 | from rhodecode.translation import _ | |
|
29 | 32 | |
|
30 | 33 | from .navigation import navigation_list |
|
31 | 34 | |
|
32 | 35 | |
|
33 | 36 | log = logging.getLogger(__name__) |
|
34 | 37 | |
|
35 | 38 | |
|
36 | 39 | class AdminSettingsView(object): |
|
37 | 40 | |
|
38 | 41 | def __init__(self, context, request): |
|
39 | 42 | self.request = request |
|
40 | 43 | self.context = context |
|
41 | 44 | self.session = request.session |
|
42 | 45 | self._rhodecode_user = request.user |
|
43 | 46 | |
|
44 | 47 | @LoginRequired() |
|
45 | 48 | @HasPermissionAllDecorator('hg.admin') |
|
46 | 49 | @view_config( |
|
47 | 50 | route_name='admin_settings_open_source', request_method='GET', |
|
48 | 51 | renderer='rhodecode:templates/admin/settings/settings.html') |
|
49 | 52 | def open_source_licenses(self): |
|
50 | 53 | c.active = 'open_source' |
|
51 | 54 | c.navlist = navigation_list(self.request) |
|
52 | 55 | c.opensource_licenses = collections.OrderedDict( |
|
53 | 56 | sorted(read_opensource_licenses().items(), key=lambda t: t[0])) |
|
54 | 57 | |
|
55 | 58 | return {} |
|
59 | ||
|
60 | @LoginRequired() | |
|
61 | @CSRFRequired() | |
|
62 | @HasPermissionAllDecorator('hg.admin') | |
|
63 | @view_config( | |
|
64 | route_name='admin_settings_vcs_svn_generate_cfg', | |
|
65 | request_method='POST', renderer='json') | |
|
66 | def vcs_svn_generate_config(self): | |
|
67 | try: | |
|
68 | generate_mod_dav_svn_config(self.request.registry) | |
|
69 | msg = { | |
|
70 | 'message': _('Apache configuration for Subversion generated.'), | |
|
71 | 'level': 'success', | |
|
72 | } | |
|
73 | except Exception: | |
|
74 | log.exception( | |
|
75 | 'Exception while generating the Apache configuration for Subversion.') | |
|
76 | msg = { | |
|
77 | 'message': _('Failed to generate the Apache configuration for Subversion.'), | |
|
78 | 'level': 'error', | |
|
79 | } | |
|
80 | ||
|
81 | data = {'message': msg} | |
|
82 | return data |
General Comments 0
You need to be logged in to leave comments.
Login now