Show More
@@ -0,0 +1,19 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | ||||
|
3 | # Copyright (C) 2016-2017 RhodeCode GmbH | |||
|
4 | # | |||
|
5 | # This program is free software: you can redistribute it and/or modify | |||
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |||
|
7 | # (only), as published by the Free Software Foundation. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
14 | # You should have received a copy of the GNU Affero General Public License | |||
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
|
16 | # | |||
|
17 | # This program is dual-licensed. If you wish to learn more about the | |||
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |||
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ |
@@ -0,0 +1,28 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | ||||
|
3 | # Copyright (C) 2016-2017 RhodeCode GmbH | |||
|
4 | # | |||
|
5 | # This program is free software: you can redistribute it and/or modify | |||
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |||
|
7 | # (only), as published by the Free Software Foundation. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
14 | # You should have received a copy of the GNU Affero General Public License | |||
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
|
16 | # | |||
|
17 | # This program is dual-licensed. If you wish to learn more about the | |||
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |||
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |||
|
20 | ||||
|
21 | ||||
|
22 | class AdminSettingsView(object): | |||
|
23 | ||||
|
24 | def __init__(self, context, request): | |||
|
25 | self.request = request | |||
|
26 | self.context = context | |||
|
27 | self.session = request.session | |||
|
28 | self._rhodecode_user = request.user |
@@ -0,0 +1,48 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | ||||
|
3 | # Copyright (C) 2016-2017 RhodeCode GmbH | |||
|
4 | # | |||
|
5 | # This program is free software: you can redistribute it and/or modify | |||
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |||
|
7 | # (only), as published by the Free Software Foundation. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
14 | # You should have received a copy of the GNU Affero General Public License | |||
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
|
16 | # | |||
|
17 | # This program is dual-licensed. If you wish to learn more about the | |||
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |||
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |||
|
20 | ||||
|
21 | import collections | |||
|
22 | import logging | |||
|
23 | ||||
|
24 | from pylons import tmpl_context as c | |||
|
25 | from pyramid.view import view_config | |||
|
26 | ||||
|
27 | from rhodecode.admin.views.base import AdminSettingsView | |||
|
28 | from rhodecode.admin.navigation import navigation_list | |||
|
29 | from rhodecode.lib.auth import (LoginRequired, HasPermissionAllDecorator) | |||
|
30 | from rhodecode.lib.utils import read_opensource_licenses | |||
|
31 | ||||
|
32 | log = logging.getLogger(__name__) | |||
|
33 | ||||
|
34 | ||||
|
35 | class OpenSourceLicensesAdminSettingsView(AdminSettingsView): | |||
|
36 | ||||
|
37 | @LoginRequired() | |||
|
38 | @HasPermissionAllDecorator('hg.admin') | |||
|
39 | @view_config( | |||
|
40 | route_name='admin_settings_open_source', request_method='GET', | |||
|
41 | renderer='rhodecode:templates/admin/settings/settings.mako') | |||
|
42 | def open_source_licenses(self): | |||
|
43 | c.active = 'open_source' | |||
|
44 | c.navlist = navigation_list(self.request) | |||
|
45 | c.opensource_licenses = collections.OrderedDict( | |||
|
46 | sorted(read_opensource_licenses().items(), key=lambda t: t[0])) | |||
|
47 | ||||
|
48 | return {} |
@@ -0,0 +1,101 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | ||||
|
3 | # Copyright (C) 2016-2017 RhodeCode GmbH | |||
|
4 | # | |||
|
5 | # This program is free software: you can redistribute it and/or modify | |||
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |||
|
7 | # (only), as published by the Free Software Foundation. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
14 | # You should have received a copy of the GNU Affero General Public License | |||
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
|
16 | # | |||
|
17 | # This program is dual-licensed. If you wish to learn more about the | |||
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |||
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |||
|
20 | ||||
|
21 | import collections | |||
|
22 | import logging | |||
|
23 | ||||
|
24 | from pylons import tmpl_context as c | |||
|
25 | from pyramid.view import view_config | |||
|
26 | from pyramid.httpexceptions import HTTPFound | |||
|
27 | ||||
|
28 | from rhodecode.translation import _ | |||
|
29 | ||||
|
30 | from rhodecode.admin.views.base import AdminSettingsView | |||
|
31 | from rhodecode.lib.auth import ( | |||
|
32 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) | |||
|
33 | from rhodecode.lib.utils2 import safe_int | |||
|
34 | from rhodecode.lib import system_info | |||
|
35 | from rhodecode.lib import user_sessions | |||
|
36 | ||||
|
37 | ||||
|
38 | from rhodecode.admin.navigation import navigation_list | |||
|
39 | ||||
|
40 | ||||
|
41 | log = logging.getLogger(__name__) | |||
|
42 | ||||
|
43 | ||||
|
44 | class AdminSessionSettingsView(AdminSettingsView): | |||
|
45 | ||||
|
46 | @LoginRequired() | |||
|
47 | @HasPermissionAllDecorator('hg.admin') | |||
|
48 | @view_config( | |||
|
49 | route_name='admin_settings_sessions', request_method='GET', | |||
|
50 | renderer='rhodecode:templates/admin/settings/settings.mako') | |||
|
51 | def settings_sessions(self): | |||
|
52 | c.active = 'sessions' | |||
|
53 | c.navlist = navigation_list(self.request) | |||
|
54 | ||||
|
55 | c.cleanup_older_days = 60 | |||
|
56 | older_than_seconds = 24 * 60 * 60 * 24 * c.cleanup_older_days | |||
|
57 | ||||
|
58 | config = system_info.rhodecode_config().get_value()['value']['config'] | |||
|
59 | c.session_model = user_sessions.get_session_handler( | |||
|
60 | config.get('beaker.session.type', 'memory'))(config) | |||
|
61 | ||||
|
62 | c.session_conf = c.session_model.config | |||
|
63 | c.session_count = c.session_model.get_count() | |||
|
64 | c.session_expired_count = c.session_model.get_expired_count( | |||
|
65 | older_than_seconds) | |||
|
66 | ||||
|
67 | return {} | |||
|
68 | ||||
|
69 | @LoginRequired() | |||
|
70 | @CSRFRequired() | |||
|
71 | @HasPermissionAllDecorator('hg.admin') | |||
|
72 | @view_config( | |||
|
73 | route_name='admin_settings_sessions_cleanup', request_method='POST') | |||
|
74 | def settings_sessions_cleanup(self): | |||
|
75 | ||||
|
76 | expire_days = safe_int(self.request.params.get('expire_days')) | |||
|
77 | ||||
|
78 | if expire_days is None: | |||
|
79 | expire_days = 60 | |||
|
80 | ||||
|
81 | older_than_seconds = 24 * 60 * 60 * 24 * expire_days | |||
|
82 | ||||
|
83 | config = system_info.rhodecode_config().get_value()['value']['config'] | |||
|
84 | session_model = user_sessions.get_session_handler( | |||
|
85 | config.get('beaker.session.type', 'memory'))(config) | |||
|
86 | ||||
|
87 | try: | |||
|
88 | session_model.clean_sessions( | |||
|
89 | older_than_seconds=older_than_seconds) | |||
|
90 | self.request.session.flash( | |||
|
91 | _('Cleaned up old sessions'), queue='success') | |||
|
92 | except user_sessions.CleanupCommand as msg: | |||
|
93 | self.request.session.flash(msg, category='warning') | |||
|
94 | except Exception as e: | |||
|
95 | log.exception('Failed session cleanup') | |||
|
96 | self.request.session.flash( | |||
|
97 | _('Failed to cleanup up old sessions'), queue='error') | |||
|
98 | ||||
|
99 | redirect_to = self.request.resource_path( | |||
|
100 | self.context, route_name='admin_settings_sessions') | |||
|
101 | return HTTPFound(redirect_to) |
@@ -0,0 +1,60 b'' | |||||
|
1 | # -*- coding: utf-8 -*- | |||
|
2 | ||||
|
3 | # Copyright (C) 2016-2017 RhodeCode GmbH | |||
|
4 | # | |||
|
5 | # This program is free software: you can redistribute it and/or modify | |||
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |||
|
7 | # (only), as published by the Free Software Foundation. | |||
|
8 | # | |||
|
9 | # This program is distributed in the hope that it will be useful, | |||
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |||
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |||
|
12 | # GNU General Public License for more details. | |||
|
13 | # | |||
|
14 | # You should have received a copy of the GNU Affero General Public License | |||
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |||
|
16 | # | |||
|
17 | # This program is dual-licensed. If you wish to learn more about the | |||
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |||
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |||
|
20 | ||||
|
21 | import logging | |||
|
22 | ||||
|
23 | from pyramid.view import view_config | |||
|
24 | ||||
|
25 | from rhodecode.translation import _ | |||
|
26 | from rhodecode.svn_support.utils import generate_mod_dav_svn_config | |||
|
27 | ||||
|
28 | from rhodecode.admin.views.base import AdminSettingsView | |||
|
29 | from rhodecode.lib.auth import ( | |||
|
30 | LoginRequired, HasPermissionAllDecorator, CSRFRequired) | |||
|
31 | ||||
|
32 | log = logging.getLogger(__name__) | |||
|
33 | ||||
|
34 | ||||
|
35 | class SvnConfigAdminSettingsView(AdminSettingsView): | |||
|
36 | ||||
|
37 | @LoginRequired() | |||
|
38 | @CSRFRequired() | |||
|
39 | @HasPermissionAllDecorator('hg.admin') | |||
|
40 | @view_config( | |||
|
41 | route_name='admin_settings_vcs_svn_generate_cfg', | |||
|
42 | request_method='POST', renderer='json') | |||
|
43 | def vcs_svn_generate_config(self): | |||
|
44 | try: | |||
|
45 | generate_mod_dav_svn_config(self.request.registry) | |||
|
46 | msg = { | |||
|
47 | 'message': _('Apache configuration for Subversion generated.'), | |||
|
48 | 'level': 'success', | |||
|
49 | } | |||
|
50 | except Exception: | |||
|
51 | log.exception( | |||
|
52 | 'Exception while generating the Apache ' | |||
|
53 | 'configuration for Subversion.') | |||
|
54 | msg = { | |||
|
55 | 'message': _('Failed to generate the Apache configuration for Subversion.'), | |||
|
56 | 'level': 'error', | |||
|
57 | } | |||
|
58 | ||||
|
59 | data = {'message': msg} | |||
|
60 | return data |
1 | NO CONTENT: file was removed |
|
NO CONTENT: file was removed |
General Comments 0
You need to be logged in to leave comments.
Login now