Show More
@@ -1,70 +1,68 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2011-2017 RhodeCode GmbH |
|
3 | # Copyright (C) 2011-2017 RhodeCode GmbH | |
4 | # |
|
4 | # | |
5 | # This program is free software: you can redistribute it and/or modify |
|
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 |
|
6 | # it under the terms of the GNU Affero General Public License, version 3 | |
7 | # (only), as published by the Free Software Foundation. |
|
7 | # (only), as published by the Free Software Foundation. | |
8 | # |
|
8 | # | |
9 | # This program is distributed in the hope that it will be useful, |
|
9 | # This program is distributed in the hope that it will be useful, | |
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 | # GNU General Public License for more details. |
|
12 | # GNU General Public License for more details. | |
13 | # |
|
13 | # | |
14 | # You should have received a copy of the GNU Affero General Public License |
|
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/>. |
|
15 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
16 | # |
|
16 | # | |
17 | # This program is dual-licensed. If you wish to learn more about the |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
18 | # RhodeCode Enterprise Edition, including its added features, Support services, |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
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 | import logging |
|
21 | import logging | |
22 |
|
22 | |||
23 | from pyramid.view import view_config |
|
23 | from pyramid.view import view_config | |
24 |
|
24 | |||
25 | from rhodecode.apps._base import RepoAppView |
|
25 | from rhodecode.apps._base import RepoAppView | |
26 | from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator, |
|
26 | from rhodecode.lib.auth import (LoginRequired, HasRepoPermissionAnyDecorator, | |
27 | NotAnonymous) |
|
27 | NotAnonymous) | |
28 | from rhodecode.lib import repo_maintenance |
|
28 | from rhodecode.lib import repo_maintenance | |
29 |
|
29 | |||
30 | log = logging.getLogger(__name__) |
|
30 | log = logging.getLogger(__name__) | |
31 |
|
31 | |||
32 |
|
32 | |||
33 | class RepoMaintenanceView(RepoAppView): |
|
33 | class RepoMaintenanceView(RepoAppView): | |
34 | def load_default_context(self): |
|
34 | def load_default_context(self): | |
35 | c = self._get_local_tmpl_context() |
|
35 | c = self._get_local_tmpl_context() | |
36 |
|
36 | |||
37 | # TODO(marcink): remove repo_info and use c.rhodecode_db_repo instead |
|
37 | # TODO(marcink): remove repo_info and use c.rhodecode_db_repo instead | |
38 | c.repo_info = self.db_repo |
|
38 | c.repo_info = self.db_repo | |
39 |
|
39 | |||
40 | self._register_global_c(c) |
|
40 | self._register_global_c(c) | |
41 | return c |
|
41 | return c | |
42 |
|
42 | |||
43 | @LoginRequired() |
|
43 | @LoginRequired() | |
44 | @NotAnonymous() |
|
|||
45 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
44 | @HasRepoPermissionAnyDecorator('repository.admin') | |
46 | @view_config( |
|
45 | @view_config( | |
47 | route_name='repo_maintenance', request_method='GET', |
|
46 | route_name='repo_maintenance', request_method='GET', | |
48 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
47 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
49 | def repo_maintenance(self): |
|
48 | def repo_maintenance(self): | |
50 | c = self.load_default_context() |
|
49 | c = self.load_default_context() | |
51 | c.active = 'maintenance' |
|
50 | c.active = 'maintenance' | |
52 | maintenance = repo_maintenance.RepoMaintenance() |
|
51 | maintenance = repo_maintenance.RepoMaintenance() | |
53 | c.executable_tasks = maintenance.get_tasks_for_repo(self.db_repo) |
|
52 | c.executable_tasks = maintenance.get_tasks_for_repo(self.db_repo) | |
54 | return self._get_template_context(c) |
|
53 | return self._get_template_context(c) | |
55 |
|
54 | |||
56 | @LoginRequired() |
|
55 | @LoginRequired() | |
57 | @NotAnonymous() |
|
|||
58 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
56 | @HasRepoPermissionAnyDecorator('repository.admin') | |
59 | @view_config( |
|
57 | @view_config( | |
60 | route_name='repo_maintenance_execute', request_method='GET', |
|
58 | route_name='repo_maintenance_execute', request_method='GET', | |
61 | renderer='json', xhr=True) |
|
59 | renderer='json', xhr=True) | |
62 | def repo_maintenance_execute(self): |
|
60 | def repo_maintenance_execute(self): | |
63 | c = self.load_default_context() |
|
61 | c = self.load_default_context() | |
64 | c.active = 'maintenance' |
|
62 | c.active = 'maintenance' | |
65 | _ = self.request.translate |
|
63 | _ = self.request.translate | |
66 |
|
64 | |||
67 | maintenance = repo_maintenance.RepoMaintenance() |
|
65 | maintenance = repo_maintenance.RepoMaintenance() | |
68 | executed_types = maintenance.execute(self.db_repo) |
|
66 | executed_types = maintenance.execute(self.db_repo) | |
69 |
|
67 | |||
70 | return executed_types |
|
68 | return executed_types |
General Comments 0
You need to be logged in to leave comments.
Login now