Show More
@@ -1,60 +1,61 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2016-2018 RhodeCode GmbH |
|
3 | # Copyright (C) 2016-2018 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.apps.repository.utils import get_default_reviewers_data |
|
26 | from rhodecode.apps.repository.utils import get_default_reviewers_data | |
27 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator |
|
27 | from rhodecode.lib.auth import LoginRequired, HasRepoPermissionAnyDecorator | |
|
28 | from rhodecode.model.db import Repository | |||
28 |
|
29 | |||
29 | log = logging.getLogger(__name__) |
|
30 | log = logging.getLogger(__name__) | |
30 |
|
31 | |||
31 |
|
32 | |||
32 | class RepoReviewRulesView(RepoAppView): |
|
33 | class RepoReviewRulesView(RepoAppView): | |
33 | def load_default_context(self): |
|
34 | def load_default_context(self): | |
34 | c = self._get_local_tmpl_context() |
|
35 | c = self._get_local_tmpl_context() | |
35 | return c |
|
36 | return c | |
36 |
|
37 | |||
37 | @LoginRequired() |
|
38 | @LoginRequired() | |
38 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
39 | @HasRepoPermissionAnyDecorator('repository.admin') | |
39 | @view_config( |
|
40 | @view_config( | |
40 | route_name='repo_reviewers', request_method='GET', |
|
41 | route_name='repo_reviewers', request_method='GET', | |
41 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
42 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
42 | def repo_review_rules(self): |
|
43 | def repo_review_rules(self): | |
43 | c = self.load_default_context() |
|
44 | c = self.load_default_context() | |
44 | c.active = 'reviewers' |
|
45 | c.active = 'reviewers' | |
45 |
|
46 | |||
46 | return self._get_template_context(c) |
|
47 | return self._get_template_context(c) | |
47 |
|
48 | |||
48 | @LoginRequired() |
|
49 | @LoginRequired() | |
49 | @HasRepoPermissionAnyDecorator( |
|
50 | @HasRepoPermissionAnyDecorator( | |
50 | 'repository.read', 'repository.write', 'repository.admin') |
|
51 | 'repository.read', 'repository.write', 'repository.admin') | |
51 | @view_config( |
|
52 | @view_config( | |
52 | route_name='repo_default_reviewers_data', request_method='GET', |
|
53 | route_name='repo_default_reviewers_data', request_method='GET', | |
53 | renderer='json_ext') |
|
54 | renderer='json_ext') | |
54 | def repo_default_reviewers_data(self): |
|
55 | def repo_default_reviewers_data(self): | |
55 | self.load_default_context() |
|
56 | self.load_default_context() | |
|
57 | target_repo_name = self.request.GET.get('target_repo', self.db_repo.repo_name) | |||
|
58 | target_repo = Repository.get_by_repo_name(target_repo_name) | |||
56 | review_data = get_default_reviewers_data( |
|
59 | review_data = get_default_reviewers_data( | |
57 |
self.db_repo.user, None, None, |
|
60 | self.db_repo.user, None, None, target_repo, None) | |
58 | return review_data |
|
61 | return review_data | |
59 |
|
||||
60 |
|
General Comments 0
You need to be logged in to leave comments.
Login now