Show More
@@ -1,105 +1,112 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2011-2019 RhodeCode GmbH |
|
3 | # Copyright (C) 2011-2019 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 | from pyramid.httpexceptions import HTTPFound |
|
24 | from pyramid.httpexceptions import HTTPFound | |
25 |
|
25 | |||
26 | from rhodecode.apps._base import RepoGroupAppView |
|
26 | from rhodecode.apps._base import RepoGroupAppView | |
27 | from rhodecode.lib import helpers as h |
|
27 | from rhodecode.lib import helpers as h | |
28 | from rhodecode.lib import audit_logger |
|
28 | from rhodecode.lib import audit_logger | |
29 | from rhodecode.lib.auth import ( |
|
29 | from rhodecode.lib.auth import ( | |
30 | LoginRequired, CSRFRequired, HasRepoGroupPermissionAnyDecorator) |
|
30 | LoginRequired, CSRFRequired, HasRepoGroupPermissionAnyDecorator) | |
31 | from rhodecode.model.repo_group import RepoGroupModel |
|
31 | from rhodecode.model.repo_group import RepoGroupModel | |
32 | from rhodecode.model.meta import Session |
|
32 | from rhodecode.model.meta import Session | |
33 |
|
33 | |||
34 | log = logging.getLogger(__name__) |
|
34 | log = logging.getLogger(__name__) | |
35 |
|
35 | |||
36 |
|
36 | |||
37 | class RepoGroupSettingsView(RepoGroupAppView): |
|
37 | class RepoGroupSettingsView(RepoGroupAppView): | |
38 | def load_default_context(self): |
|
38 | def load_default_context(self): | |
39 | c = self._get_local_tmpl_context() |
|
39 | c = self._get_local_tmpl_context() | |
40 |
|
40 | |||
41 | return c |
|
41 | return c | |
42 |
|
42 | |||
43 | @LoginRequired() |
|
43 | @LoginRequired() | |
44 | @HasRepoGroupPermissionAnyDecorator('group.admin') |
|
44 | @HasRepoGroupPermissionAnyDecorator('group.admin') | |
45 | @view_config( |
|
45 | @view_config( | |
46 | route_name='edit_repo_group_advanced', request_method='GET', |
|
46 | route_name='edit_repo_group_advanced', request_method='GET', | |
47 | renderer='rhodecode:templates/admin/repo_groups/repo_group_edit.mako') |
|
47 | renderer='rhodecode:templates/admin/repo_groups/repo_group_edit.mako') | |
48 | def edit_repo_group_advanced(self): |
|
48 | def edit_repo_group_advanced(self): | |
|
49 | _ = self.request.translate | |||
49 | c = self.load_default_context() |
|
50 | c = self.load_default_context() | |
50 | c.active = 'advanced' |
|
51 | c.active = 'advanced' | |
51 | c.repo_group = self.db_repo_group |
|
52 | c.repo_group = self.db_repo_group | |
|
53 | ||||
|
54 | # update commit cache if GET flag is present | |||
|
55 | if self.request.GET.get('update_commit_cache'): | |||
|
56 | self.db_repo_group.update_commit_cache() | |||
|
57 | h.flash(_('updated commit cache'), category='success') | |||
|
58 | ||||
52 | return self._get_template_context(c) |
|
59 | return self._get_template_context(c) | |
53 |
|
60 | |||
54 | @LoginRequired() |
|
61 | @LoginRequired() | |
55 | @HasRepoGroupPermissionAnyDecorator('group.admin') |
|
62 | @HasRepoGroupPermissionAnyDecorator('group.admin') | |
56 | @CSRFRequired() |
|
63 | @CSRFRequired() | |
57 | @view_config( |
|
64 | @view_config( | |
58 | route_name='edit_repo_group_advanced_delete', request_method='POST', |
|
65 | route_name='edit_repo_group_advanced_delete', request_method='POST', | |
59 | renderer='rhodecode:templates/admin/repo_groups/repo_group_edit.mako') |
|
66 | renderer='rhodecode:templates/admin/repo_groups/repo_group_edit.mako') | |
60 | def edit_repo_group_delete(self): |
|
67 | def edit_repo_group_delete(self): | |
61 | _ = self.request.translate |
|
68 | _ = self.request.translate | |
62 | _ungettext = self.request.plularize |
|
69 | _ungettext = self.request.plularize | |
63 | c = self.load_default_context() |
|
70 | c = self.load_default_context() | |
64 | c.repo_group = self.db_repo_group |
|
71 | c.repo_group = self.db_repo_group | |
65 |
|
72 | |||
66 | repos = c.repo_group.repositories.all() |
|
73 | repos = c.repo_group.repositories.all() | |
67 | if repos: |
|
74 | if repos: | |
68 | msg = _ungettext( |
|
75 | msg = _ungettext( | |
69 | 'This repository group contains %(num)d repository and cannot be deleted', |
|
76 | 'This repository group contains %(num)d repository and cannot be deleted', | |
70 | 'This repository group contains %(num)d repositories and cannot be' |
|
77 | 'This repository group contains %(num)d repositories and cannot be' | |
71 | ' deleted', |
|
78 | ' deleted', | |
72 | len(repos)) % {'num': len(repos)} |
|
79 | len(repos)) % {'num': len(repos)} | |
73 | h.flash(msg, category='warning') |
|
80 | h.flash(msg, category='warning') | |
74 | raise HTTPFound( |
|
81 | raise HTTPFound( | |
75 | h.route_path('edit_repo_group_advanced', |
|
82 | h.route_path('edit_repo_group_advanced', | |
76 | repo_group_name=self.db_repo_group_name)) |
|
83 | repo_group_name=self.db_repo_group_name)) | |
77 |
|
84 | |||
78 | children = c.repo_group.children.all() |
|
85 | children = c.repo_group.children.all() | |
79 | if children: |
|
86 | if children: | |
80 | msg = _ungettext( |
|
87 | msg = _ungettext( | |
81 | 'This repository group contains %(num)d subgroup and cannot be deleted', |
|
88 | 'This repository group contains %(num)d subgroup and cannot be deleted', | |
82 | 'This repository group contains %(num)d subgroups and cannot be deleted', |
|
89 | 'This repository group contains %(num)d subgroups and cannot be deleted', | |
83 | len(children)) % {'num': len(children)} |
|
90 | len(children)) % {'num': len(children)} | |
84 | h.flash(msg, category='warning') |
|
91 | h.flash(msg, category='warning') | |
85 | raise HTTPFound( |
|
92 | raise HTTPFound( | |
86 | h.route_path('edit_repo_group_advanced', |
|
93 | h.route_path('edit_repo_group_advanced', | |
87 | repo_group_name=self.db_repo_group_name)) |
|
94 | repo_group_name=self.db_repo_group_name)) | |
88 |
|
95 | |||
89 | try: |
|
96 | try: | |
90 | old_values = c.repo_group.get_api_data() |
|
97 | old_values = c.repo_group.get_api_data() | |
91 | RepoGroupModel().delete(self.db_repo_group_name) |
|
98 | RepoGroupModel().delete(self.db_repo_group_name) | |
92 |
|
99 | |||
93 | audit_logger.store_web( |
|
100 | audit_logger.store_web( | |
94 | 'repo_group.delete', action_data={'old_data': old_values}, |
|
101 | 'repo_group.delete', action_data={'old_data': old_values}, | |
95 | user=c.rhodecode_user) |
|
102 | user=c.rhodecode_user) | |
96 |
|
103 | |||
97 | Session().commit() |
|
104 | Session().commit() | |
98 | h.flash(_('Removed repository group `%s`') % self.db_repo_group_name, |
|
105 | h.flash(_('Removed repository group `%s`') % self.db_repo_group_name, | |
99 | category='success') |
|
106 | category='success') | |
100 | except Exception: |
|
107 | except Exception: | |
101 | log.exception("Exception during deletion of repository group") |
|
108 | log.exception("Exception during deletion of repository group") | |
102 | h.flash(_('Error occurred during deletion of repository group %s') |
|
109 | h.flash(_('Error occurred during deletion of repository group %s') | |
103 | % self.db_repo_group_name, category='error') |
|
110 | % self.db_repo_group_name, category='error') | |
104 |
|
111 | |||
105 | raise HTTPFound(h.route_path('repo_groups')) |
|
112 | raise HTTPFound(h.route_path('repo_groups')) |
@@ -1,311 +1,317 b'' | |||||
1 | # -*- coding: utf-8 -*- |
|
1 | # -*- coding: utf-8 -*- | |
2 |
|
2 | |||
3 | # Copyright (C) 2011-2019 RhodeCode GmbH |
|
3 | # Copyright (C) 2011-2019 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 | from pyramid.httpexceptions import HTTPFound |
|
24 | from pyramid.httpexceptions import HTTPFound | |
25 |
|
25 | |||
26 | from rhodecode import events |
|
26 | from rhodecode import events | |
27 | from rhodecode.apps._base import RepoAppView |
|
27 | from rhodecode.apps._base import RepoAppView | |
28 | from rhodecode.lib import helpers as h |
|
28 | from rhodecode.lib import helpers as h | |
29 | from rhodecode.lib import audit_logger |
|
29 | from rhodecode.lib import audit_logger | |
30 | from rhodecode.lib.auth import ( |
|
30 | from rhodecode.lib.auth import ( | |
31 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired, |
|
31 | LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired, | |
32 | HasRepoPermissionAny) |
|
32 | HasRepoPermissionAny) | |
33 | from rhodecode.lib.exceptions import AttachedForksError, AttachedPullRequestsError |
|
33 | from rhodecode.lib.exceptions import AttachedForksError, AttachedPullRequestsError | |
34 | from rhodecode.lib.utils2 import safe_int |
|
34 | from rhodecode.lib.utils2 import safe_int | |
35 | from rhodecode.lib.vcs import RepositoryError |
|
35 | from rhodecode.lib.vcs import RepositoryError | |
36 | from rhodecode.model.db import Session, UserFollowing, User, Repository |
|
36 | from rhodecode.model.db import Session, UserFollowing, User, Repository | |
37 | from rhodecode.model.permission import PermissionModel |
|
37 | from rhodecode.model.permission import PermissionModel | |
38 | from rhodecode.model.repo import RepoModel |
|
38 | from rhodecode.model.repo import RepoModel | |
39 | from rhodecode.model.scm import ScmModel |
|
39 | from rhodecode.model.scm import ScmModel | |
40 |
|
40 | |||
41 | log = logging.getLogger(__name__) |
|
41 | log = logging.getLogger(__name__) | |
42 |
|
42 | |||
43 |
|
43 | |||
44 | class RepoSettingsView(RepoAppView): |
|
44 | class RepoSettingsView(RepoAppView): | |
45 |
|
45 | |||
46 | def load_default_context(self): |
|
46 | def load_default_context(self): | |
47 | c = self._get_local_tmpl_context() |
|
47 | c = self._get_local_tmpl_context() | |
48 | return c |
|
48 | return c | |
49 |
|
49 | |||
50 | def _get_users_with_permissions(self): |
|
50 | def _get_users_with_permissions(self): | |
51 | user_permissions = {} |
|
51 | user_permissions = {} | |
52 | for perm in self.db_repo.permissions(): |
|
52 | for perm in self.db_repo.permissions(): | |
53 | user_permissions[perm.user_id] = perm |
|
53 | user_permissions[perm.user_id] = perm | |
54 |
|
54 | |||
55 | return user_permissions |
|
55 | return user_permissions | |
56 |
|
56 | |||
57 | @LoginRequired() |
|
57 | @LoginRequired() | |
58 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
58 | @HasRepoPermissionAnyDecorator('repository.admin') | |
59 | @view_config( |
|
59 | @view_config( | |
60 | route_name='edit_repo_advanced', request_method='GET', |
|
60 | route_name='edit_repo_advanced', request_method='GET', | |
61 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
61 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
62 | def edit_advanced(self): |
|
62 | def edit_advanced(self): | |
|
63 | _ = self.request.translate | |||
63 | c = self.load_default_context() |
|
64 | c = self.load_default_context() | |
64 | c.active = 'advanced' |
|
65 | c.active = 'advanced' | |
65 |
|
66 | |||
66 | c.default_user_id = User.get_default_user().user_id |
|
67 | c.default_user_id = User.get_default_user().user_id | |
67 | c.in_public_journal = UserFollowing.query() \ |
|
68 | c.in_public_journal = UserFollowing.query() \ | |
68 | .filter(UserFollowing.user_id == c.default_user_id) \ |
|
69 | .filter(UserFollowing.user_id == c.default_user_id) \ | |
69 | .filter(UserFollowing.follows_repository == self.db_repo).scalar() |
|
70 | .filter(UserFollowing.follows_repository == self.db_repo).scalar() | |
70 |
|
71 | |||
71 | c.ver_info_dict = self.rhodecode_vcs_repo.get_hooks_info() |
|
72 | c.ver_info_dict = self.rhodecode_vcs_repo.get_hooks_info() | |
72 |
|
73 | |||
|
74 | # update commit cache if GET flag is present | |||
|
75 | if self.request.GET.get('update_commit_cache'): | |||
|
76 | self.db_repo.update_commit_cache() | |||
|
77 | h.flash(_('updated commit cache'), category='success') | |||
|
78 | ||||
73 | return self._get_template_context(c) |
|
79 | return self._get_template_context(c) | |
74 |
|
80 | |||
75 | @LoginRequired() |
|
81 | @LoginRequired() | |
76 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
82 | @HasRepoPermissionAnyDecorator('repository.admin') | |
77 | @CSRFRequired() |
|
83 | @CSRFRequired() | |
78 | @view_config( |
|
84 | @view_config( | |
79 | route_name='edit_repo_advanced_archive', request_method='POST', |
|
85 | route_name='edit_repo_advanced_archive', request_method='POST', | |
80 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
86 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
81 | def edit_advanced_archive(self): |
|
87 | def edit_advanced_archive(self): | |
82 | """ |
|
88 | """ | |
83 | Archives the repository. It will become read-only, and not visible in search |
|
89 | Archives the repository. It will become read-only, and not visible in search | |
84 | or other queries. But still visible for super-admins. |
|
90 | or other queries. But still visible for super-admins. | |
85 | """ |
|
91 | """ | |
86 |
|
92 | |||
87 | _ = self.request.translate |
|
93 | _ = self.request.translate | |
88 |
|
94 | |||
89 | try: |
|
95 | try: | |
90 | old_data = self.db_repo.get_api_data() |
|
96 | old_data = self.db_repo.get_api_data() | |
91 | RepoModel().archive(self.db_repo) |
|
97 | RepoModel().archive(self.db_repo) | |
92 |
|
98 | |||
93 | repo = audit_logger.RepoWrap(repo_id=None, repo_name=self.db_repo.repo_name) |
|
99 | repo = audit_logger.RepoWrap(repo_id=None, repo_name=self.db_repo.repo_name) | |
94 | audit_logger.store_web( |
|
100 | audit_logger.store_web( | |
95 | 'repo.archive', action_data={'old_data': old_data}, |
|
101 | 'repo.archive', action_data={'old_data': old_data}, | |
96 | user=self._rhodecode_user, repo=repo) |
|
102 | user=self._rhodecode_user, repo=repo) | |
97 |
|
103 | |||
98 | ScmModel().mark_for_invalidation(self.db_repo_name, delete=True) |
|
104 | ScmModel().mark_for_invalidation(self.db_repo_name, delete=True) | |
99 | h.flash( |
|
105 | h.flash( | |
100 | _('Archived repository `%s`') % self.db_repo_name, |
|
106 | _('Archived repository `%s`') % self.db_repo_name, | |
101 | category='success') |
|
107 | category='success') | |
102 | Session().commit() |
|
108 | Session().commit() | |
103 | except Exception: |
|
109 | except Exception: | |
104 | log.exception("Exception during archiving of repository") |
|
110 | log.exception("Exception during archiving of repository") | |
105 | h.flash(_('An error occurred during archiving of `%s`') |
|
111 | h.flash(_('An error occurred during archiving of `%s`') | |
106 | % self.db_repo_name, category='error') |
|
112 | % self.db_repo_name, category='error') | |
107 | # redirect to advanced for more deletion options |
|
113 | # redirect to advanced for more deletion options | |
108 | raise HTTPFound( |
|
114 | raise HTTPFound( | |
109 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name, |
|
115 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name, | |
110 | _anchor='advanced-archive')) |
|
116 | _anchor='advanced-archive')) | |
111 |
|
117 | |||
112 | # flush permissions for all users defined in permissions |
|
118 | # flush permissions for all users defined in permissions | |
113 | affected_user_ids = self._get_users_with_permissions().keys() |
|
119 | affected_user_ids = self._get_users_with_permissions().keys() | |
114 | PermissionModel().trigger_permission_flush(affected_user_ids) |
|
120 | PermissionModel().trigger_permission_flush(affected_user_ids) | |
115 |
|
121 | |||
116 | raise HTTPFound(h.route_path('home')) |
|
122 | raise HTTPFound(h.route_path('home')) | |
117 |
|
123 | |||
118 | @LoginRequired() |
|
124 | @LoginRequired() | |
119 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
125 | @HasRepoPermissionAnyDecorator('repository.admin') | |
120 | @CSRFRequired() |
|
126 | @CSRFRequired() | |
121 | @view_config( |
|
127 | @view_config( | |
122 | route_name='edit_repo_advanced_delete', request_method='POST', |
|
128 | route_name='edit_repo_advanced_delete', request_method='POST', | |
123 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
129 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
124 | def edit_advanced_delete(self): |
|
130 | def edit_advanced_delete(self): | |
125 | """ |
|
131 | """ | |
126 | Deletes the repository, or shows warnings if deletion is not possible |
|
132 | Deletes the repository, or shows warnings if deletion is not possible | |
127 | because of attached forks or other errors. |
|
133 | because of attached forks or other errors. | |
128 | """ |
|
134 | """ | |
129 | _ = self.request.translate |
|
135 | _ = self.request.translate | |
130 | handle_forks = self.request.POST.get('forks', None) |
|
136 | handle_forks = self.request.POST.get('forks', None) | |
131 | if handle_forks == 'detach_forks': |
|
137 | if handle_forks == 'detach_forks': | |
132 | handle_forks = 'detach' |
|
138 | handle_forks = 'detach' | |
133 | elif handle_forks == 'delete_forks': |
|
139 | elif handle_forks == 'delete_forks': | |
134 | handle_forks = 'delete' |
|
140 | handle_forks = 'delete' | |
135 |
|
141 | |||
136 | try: |
|
142 | try: | |
137 | old_data = self.db_repo.get_api_data() |
|
143 | old_data = self.db_repo.get_api_data() | |
138 | RepoModel().delete(self.db_repo, forks=handle_forks) |
|
144 | RepoModel().delete(self.db_repo, forks=handle_forks) | |
139 |
|
145 | |||
140 | _forks = self.db_repo.forks.count() |
|
146 | _forks = self.db_repo.forks.count() | |
141 | if _forks and handle_forks: |
|
147 | if _forks and handle_forks: | |
142 | if handle_forks == 'detach_forks': |
|
148 | if handle_forks == 'detach_forks': | |
143 | h.flash(_('Detached %s forks') % _forks, category='success') |
|
149 | h.flash(_('Detached %s forks') % _forks, category='success') | |
144 | elif handle_forks == 'delete_forks': |
|
150 | elif handle_forks == 'delete_forks': | |
145 | h.flash(_('Deleted %s forks') % _forks, category='success') |
|
151 | h.flash(_('Deleted %s forks') % _forks, category='success') | |
146 |
|
152 | |||
147 | repo = audit_logger.RepoWrap(repo_id=None, repo_name=self.db_repo.repo_name) |
|
153 | repo = audit_logger.RepoWrap(repo_id=None, repo_name=self.db_repo.repo_name) | |
148 | audit_logger.store_web( |
|
154 | audit_logger.store_web( | |
149 | 'repo.delete', action_data={'old_data': old_data}, |
|
155 | 'repo.delete', action_data={'old_data': old_data}, | |
150 | user=self._rhodecode_user, repo=repo) |
|
156 | user=self._rhodecode_user, repo=repo) | |
151 |
|
157 | |||
152 | ScmModel().mark_for_invalidation(self.db_repo_name, delete=True) |
|
158 | ScmModel().mark_for_invalidation(self.db_repo_name, delete=True) | |
153 | h.flash( |
|
159 | h.flash( | |
154 | _('Deleted repository `%s`') % self.db_repo_name, |
|
160 | _('Deleted repository `%s`') % self.db_repo_name, | |
155 | category='success') |
|
161 | category='success') | |
156 | Session().commit() |
|
162 | Session().commit() | |
157 | except AttachedForksError: |
|
163 | except AttachedForksError: | |
158 | repo_advanced_url = h.route_path( |
|
164 | repo_advanced_url = h.route_path( | |
159 | 'edit_repo_advanced', repo_name=self.db_repo_name, |
|
165 | 'edit_repo_advanced', repo_name=self.db_repo_name, | |
160 | _anchor='advanced-delete') |
|
166 | _anchor='advanced-delete') | |
161 | delete_anchor = h.link_to(_('detach or delete'), repo_advanced_url) |
|
167 | delete_anchor = h.link_to(_('detach or delete'), repo_advanced_url) | |
162 | h.flash(_('Cannot delete `{repo}` it still contains attached forks. ' |
|
168 | h.flash(_('Cannot delete `{repo}` it still contains attached forks. ' | |
163 | 'Try using {delete_or_detach} option.') |
|
169 | 'Try using {delete_or_detach} option.') | |
164 | .format(repo=self.db_repo_name, delete_or_detach=delete_anchor), |
|
170 | .format(repo=self.db_repo_name, delete_or_detach=delete_anchor), | |
165 | category='warning') |
|
171 | category='warning') | |
166 |
|
172 | |||
167 | # redirect to advanced for forks handle action ? |
|
173 | # redirect to advanced for forks handle action ? | |
168 | raise HTTPFound(repo_advanced_url) |
|
174 | raise HTTPFound(repo_advanced_url) | |
169 |
|
175 | |||
170 | except AttachedPullRequestsError: |
|
176 | except AttachedPullRequestsError: | |
171 | repo_advanced_url = h.route_path( |
|
177 | repo_advanced_url = h.route_path( | |
172 | 'edit_repo_advanced', repo_name=self.db_repo_name, |
|
178 | 'edit_repo_advanced', repo_name=self.db_repo_name, | |
173 | _anchor='advanced-delete') |
|
179 | _anchor='advanced-delete') | |
174 | attached_prs = len(self.db_repo.pull_requests_source + |
|
180 | attached_prs = len(self.db_repo.pull_requests_source + | |
175 | self.db_repo.pull_requests_target) |
|
181 | self.db_repo.pull_requests_target) | |
176 | h.flash( |
|
182 | h.flash( | |
177 | _('Cannot delete `{repo}` it still contains {num} attached pull requests. ' |
|
183 | _('Cannot delete `{repo}` it still contains {num} attached pull requests. ' | |
178 | 'Consider archiving the repository instead.').format( |
|
184 | 'Consider archiving the repository instead.').format( | |
179 | repo=self.db_repo_name, num=attached_prs), category='warning') |
|
185 | repo=self.db_repo_name, num=attached_prs), category='warning') | |
180 |
|
186 | |||
181 | # redirect to advanced for forks handle action ? |
|
187 | # redirect to advanced for forks handle action ? | |
182 | raise HTTPFound(repo_advanced_url) |
|
188 | raise HTTPFound(repo_advanced_url) | |
183 |
|
189 | |||
184 | except Exception: |
|
190 | except Exception: | |
185 | log.exception("Exception during deletion of repository") |
|
191 | log.exception("Exception during deletion of repository") | |
186 | h.flash(_('An error occurred during deletion of `%s`') |
|
192 | h.flash(_('An error occurred during deletion of `%s`') | |
187 | % self.db_repo_name, category='error') |
|
193 | % self.db_repo_name, category='error') | |
188 | # redirect to advanced for more deletion options |
|
194 | # redirect to advanced for more deletion options | |
189 | raise HTTPFound( |
|
195 | raise HTTPFound( | |
190 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name, |
|
196 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name, | |
191 | _anchor='advanced-delete')) |
|
197 | _anchor='advanced-delete')) | |
192 |
|
198 | |||
193 | raise HTTPFound(h.route_path('home')) |
|
199 | raise HTTPFound(h.route_path('home')) | |
194 |
|
200 | |||
195 | @LoginRequired() |
|
201 | @LoginRequired() | |
196 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
202 | @HasRepoPermissionAnyDecorator('repository.admin') | |
197 | @CSRFRequired() |
|
203 | @CSRFRequired() | |
198 | @view_config( |
|
204 | @view_config( | |
199 | route_name='edit_repo_advanced_journal', request_method='POST', |
|
205 | route_name='edit_repo_advanced_journal', request_method='POST', | |
200 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
206 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
201 | def edit_advanced_journal(self): |
|
207 | def edit_advanced_journal(self): | |
202 | """ |
|
208 | """ | |
203 | Set's this repository to be visible in public journal, |
|
209 | Set's this repository to be visible in public journal, | |
204 | in other words making default user to follow this repo |
|
210 | in other words making default user to follow this repo | |
205 | """ |
|
211 | """ | |
206 | _ = self.request.translate |
|
212 | _ = self.request.translate | |
207 |
|
213 | |||
208 | try: |
|
214 | try: | |
209 | user_id = User.get_default_user().user_id |
|
215 | user_id = User.get_default_user().user_id | |
210 | ScmModel().toggle_following_repo(self.db_repo.repo_id, user_id) |
|
216 | ScmModel().toggle_following_repo(self.db_repo.repo_id, user_id) | |
211 | h.flash(_('Updated repository visibility in public journal'), |
|
217 | h.flash(_('Updated repository visibility in public journal'), | |
212 | category='success') |
|
218 | category='success') | |
213 | Session().commit() |
|
219 | Session().commit() | |
214 | except Exception: |
|
220 | except Exception: | |
215 | h.flash(_('An error occurred during setting this ' |
|
221 | h.flash(_('An error occurred during setting this ' | |
216 | 'repository in public journal'), |
|
222 | 'repository in public journal'), | |
217 | category='error') |
|
223 | category='error') | |
218 |
|
224 | |||
219 | raise HTTPFound( |
|
225 | raise HTTPFound( | |
220 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) |
|
226 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) | |
221 |
|
227 | |||
222 | @LoginRequired() |
|
228 | @LoginRequired() | |
223 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
229 | @HasRepoPermissionAnyDecorator('repository.admin') | |
224 | @CSRFRequired() |
|
230 | @CSRFRequired() | |
225 | @view_config( |
|
231 | @view_config( | |
226 | route_name='edit_repo_advanced_fork', request_method='POST', |
|
232 | route_name='edit_repo_advanced_fork', request_method='POST', | |
227 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
233 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
228 | def edit_advanced_fork(self): |
|
234 | def edit_advanced_fork(self): | |
229 | """ |
|
235 | """ | |
230 | Mark given repository as a fork of another |
|
236 | Mark given repository as a fork of another | |
231 | """ |
|
237 | """ | |
232 | _ = self.request.translate |
|
238 | _ = self.request.translate | |
233 |
|
239 | |||
234 | new_fork_id = safe_int(self.request.POST.get('id_fork_of')) |
|
240 | new_fork_id = safe_int(self.request.POST.get('id_fork_of')) | |
235 |
|
241 | |||
236 | # valid repo, re-check permissions |
|
242 | # valid repo, re-check permissions | |
237 | if new_fork_id: |
|
243 | if new_fork_id: | |
238 | repo = Repository.get(new_fork_id) |
|
244 | repo = Repository.get(new_fork_id) | |
239 | # ensure we have at least read access to the repo we mark |
|
245 | # ensure we have at least read access to the repo we mark | |
240 | perm_check = HasRepoPermissionAny( |
|
246 | perm_check = HasRepoPermissionAny( | |
241 | 'repository.read', 'repository.write', 'repository.admin') |
|
247 | 'repository.read', 'repository.write', 'repository.admin') | |
242 |
|
248 | |||
243 | if repo and perm_check(repo_name=repo.repo_name): |
|
249 | if repo and perm_check(repo_name=repo.repo_name): | |
244 | new_fork_id = repo.repo_id |
|
250 | new_fork_id = repo.repo_id | |
245 | else: |
|
251 | else: | |
246 | new_fork_id = None |
|
252 | new_fork_id = None | |
247 |
|
253 | |||
248 | try: |
|
254 | try: | |
249 | repo = ScmModel().mark_as_fork( |
|
255 | repo = ScmModel().mark_as_fork( | |
250 | self.db_repo_name, new_fork_id, self._rhodecode_user.user_id) |
|
256 | self.db_repo_name, new_fork_id, self._rhodecode_user.user_id) | |
251 | fork = repo.fork.repo_name if repo.fork else _('Nothing') |
|
257 | fork = repo.fork.repo_name if repo.fork else _('Nothing') | |
252 | Session().commit() |
|
258 | Session().commit() | |
253 | h.flash( |
|
259 | h.flash( | |
254 | _('Marked repo %s as fork of %s') % (self.db_repo_name, fork), |
|
260 | _('Marked repo %s as fork of %s') % (self.db_repo_name, fork), | |
255 | category='success') |
|
261 | category='success') | |
256 | except RepositoryError as e: |
|
262 | except RepositoryError as e: | |
257 | log.exception("Repository Error occurred") |
|
263 | log.exception("Repository Error occurred") | |
258 | h.flash(str(e), category='error') |
|
264 | h.flash(str(e), category='error') | |
259 | except Exception: |
|
265 | except Exception: | |
260 | log.exception("Exception while editing fork") |
|
266 | log.exception("Exception while editing fork") | |
261 | h.flash(_('An error occurred during this operation'), |
|
267 | h.flash(_('An error occurred during this operation'), | |
262 | category='error') |
|
268 | category='error') | |
263 |
|
269 | |||
264 | raise HTTPFound( |
|
270 | raise HTTPFound( | |
265 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) |
|
271 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) | |
266 |
|
272 | |||
267 | @LoginRequired() |
|
273 | @LoginRequired() | |
268 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
274 | @HasRepoPermissionAnyDecorator('repository.admin') | |
269 | @CSRFRequired() |
|
275 | @CSRFRequired() | |
270 | @view_config( |
|
276 | @view_config( | |
271 | route_name='edit_repo_advanced_locking', request_method='POST', |
|
277 | route_name='edit_repo_advanced_locking', request_method='POST', | |
272 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
278 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
273 | def edit_advanced_locking(self): |
|
279 | def edit_advanced_locking(self): | |
274 | """ |
|
280 | """ | |
275 | Toggle locking of repository |
|
281 | Toggle locking of repository | |
276 | """ |
|
282 | """ | |
277 | _ = self.request.translate |
|
283 | _ = self.request.translate | |
278 | set_lock = self.request.POST.get('set_lock') |
|
284 | set_lock = self.request.POST.get('set_lock') | |
279 | set_unlock = self.request.POST.get('set_unlock') |
|
285 | set_unlock = self.request.POST.get('set_unlock') | |
280 |
|
286 | |||
281 | try: |
|
287 | try: | |
282 | if set_lock: |
|
288 | if set_lock: | |
283 | Repository.lock(self.db_repo, self._rhodecode_user.user_id, |
|
289 | Repository.lock(self.db_repo, self._rhodecode_user.user_id, | |
284 | lock_reason=Repository.LOCK_WEB) |
|
290 | lock_reason=Repository.LOCK_WEB) | |
285 | h.flash(_('Locked repository'), category='success') |
|
291 | h.flash(_('Locked repository'), category='success') | |
286 | elif set_unlock: |
|
292 | elif set_unlock: | |
287 | Repository.unlock(self.db_repo) |
|
293 | Repository.unlock(self.db_repo) | |
288 | h.flash(_('Unlocked repository'), category='success') |
|
294 | h.flash(_('Unlocked repository'), category='success') | |
289 | except Exception as e: |
|
295 | except Exception as e: | |
290 | log.exception("Exception during unlocking") |
|
296 | log.exception("Exception during unlocking") | |
291 | h.flash(_('An error occurred during unlocking'), category='error') |
|
297 | h.flash(_('An error occurred during unlocking'), category='error') | |
292 |
|
298 | |||
293 | raise HTTPFound( |
|
299 | raise HTTPFound( | |
294 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) |
|
300 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) | |
295 |
|
301 | |||
296 | @LoginRequired() |
|
302 | @LoginRequired() | |
297 | @HasRepoPermissionAnyDecorator('repository.admin') |
|
303 | @HasRepoPermissionAnyDecorator('repository.admin') | |
298 | @view_config( |
|
304 | @view_config( | |
299 | route_name='edit_repo_advanced_hooks', request_method='GET', |
|
305 | route_name='edit_repo_advanced_hooks', request_method='GET', | |
300 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') |
|
306 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
301 | def edit_advanced_install_hooks(self): |
|
307 | def edit_advanced_install_hooks(self): | |
302 | """ |
|
308 | """ | |
303 | Install Hooks for repository |
|
309 | Install Hooks for repository | |
304 | """ |
|
310 | """ | |
305 | _ = self.request.translate |
|
311 | _ = self.request.translate | |
306 | self.load_default_context() |
|
312 | self.load_default_context() | |
307 | self.rhodecode_vcs_repo.install_hooks(force=True) |
|
313 | self.rhodecode_vcs_repo.install_hooks(force=True) | |
308 | h.flash(_('installed updated hooks into this repository'), |
|
314 | h.flash(_('installed updated hooks into this repository'), | |
309 | category='success') |
|
315 | category='success') | |
310 | raise HTTPFound( |
|
316 | raise HTTPFound( | |
311 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) |
|
317 | h.route_path('edit_repo_advanced', repo_name=self.db_repo_name)) |
@@ -1,71 +1,74 b'' | |||||
1 | <%namespace name="base" file="/base/base.mako"/> |
|
1 | <%namespace name="base" file="/base/base.mako"/> | |
2 |
|
2 | |||
3 | <% |
|
3 | <% | |
4 | source_repo_id = c.repo_group.changeset_cache.get('source_repo_id') |
|
4 | source_repo_id = c.repo_group.changeset_cache.get('source_repo_id') | |
5 |
|
5 | |||
6 | elems = [ |
|
6 | elems = [ | |
7 | (_('Repository Group ID'), c.repo_group.group_id, '', ''), |
|
7 | (_('Repository Group ID'), c.repo_group.group_id, '', ''), | |
8 | (_('Owner'), lambda:base.gravatar_with_user(c.repo_group.user.email, tooltip=True), '', ''), |
|
8 | (_('Owner'), lambda:base.gravatar_with_user(c.repo_group.user.email, tooltip=True), '', ''), | |
9 | (_('Created on'), h.format_date(c.repo_group.created_on), '', ''), |
|
9 | (_('Created on'), h.format_date(c.repo_group.created_on), '', ''), | |
10 | (_('Updated on'), h.format_date(c.repo_group.updated_on), '', ''), |
|
10 | (_('Updated on'), h.format_date(c.repo_group.updated_on), '', ''), | |
|
11 | (_('Cached Commit source'), (h.link_to_if(source_repo_id, 'repo_id:{}'.format(source_repo_id), h.route_path('repo_summary', repo_name='_{}'.format(source_repo_id)))), '', ''), | |||
|
12 | (_('Cached Commit id'), c.repo_group.changeset_cache.get('short_id'), '', ''), | |||
11 | (_('Cached Commit date'), (c.repo_group.changeset_cache.get('date')), '', ''), |
|
13 | (_('Cached Commit date'), (c.repo_group.changeset_cache.get('date')), '', ''), | |
12 | (_('Cached Commit repo_id'), (h.link_to_if(source_repo_id, source_repo_id, h.route_path('repo_summary', repo_name='_{}'.format(source_repo_id)))), '', ''), |
|
14 | ||
|
15 | (_('Cached Commit data'), lambda: h.link_to('refresh now', h.current_route_path(request, update_commit_cache=1)), '', ''), | |||
13 |
|
16 | |||
14 | (_('Is Personal Group'), c.repo_group.personal or False, '', ''), |
|
17 | (_('Is Personal Group'), c.repo_group.personal or False, '', ''), | |
15 |
|
18 | |||
16 | (_('Total repositories'), c.repo_group.repositories_recursive_count, '', ''), |
|
19 | (_('Total repositories'), c.repo_group.repositories_recursive_count, '', ''), | |
17 | (_('Top level repositories'), c.repo_group.repositories.count(), '', c.repo_group.repositories.all()), |
|
20 | (_('Top level repositories'), c.repo_group.repositories.count(), '', c.repo_group.repositories.all()), | |
18 |
|
21 | |||
19 | (_('Children groups'), c.repo_group.children.count(), '', c.repo_group.children.all()), |
|
22 | (_('Children groups'), c.repo_group.children.count(), '', c.repo_group.children.all()), | |
20 | ] |
|
23 | ] | |
21 | %> |
|
24 | %> | |
22 |
|
25 | |||
23 | <div class="panel panel-default"> |
|
26 | <div class="panel panel-default"> | |
24 | <div class="panel-heading"> |
|
27 | <div class="panel-heading"> | |
25 | <h3 class="panel-title">${_('Repository Group Advanced: {}').format(c.repo_group.name)}</h3> |
|
28 | <h3 class="panel-title">${_('Repository Group Advanced: {}').format(c.repo_group.name)}</h3> | |
26 | </div> |
|
29 | </div> | |
27 | <div class="panel-body"> |
|
30 | <div class="panel-body"> | |
28 | ${base.dt_info_panel(elems)} |
|
31 | ${base.dt_info_panel(elems)} | |
29 | </div> |
|
32 | </div> | |
30 |
|
33 | |||
31 | </div> |
|
34 | </div> | |
32 |
|
35 | |||
33 | <div class="panel panel-danger"> |
|
36 | <div class="panel panel-danger"> | |
34 | <div class="panel-heading"> |
|
37 | <div class="panel-heading"> | |
35 | <h3 class="panel-title">${_('Delete repository group')}</h3> |
|
38 | <h3 class="panel-title">${_('Delete repository group')}</h3> | |
36 | </div> |
|
39 | </div> | |
37 | <div class="panel-body"> |
|
40 | <div class="panel-body"> | |
38 | ${h.secure_form(h.route_path('edit_repo_group_advanced_delete', repo_group_name=c.repo_group.group_name), request=request)} |
|
41 | ${h.secure_form(h.route_path('edit_repo_group_advanced_delete', repo_group_name=c.repo_group.group_name), request=request)} | |
39 | <table class="display"> |
|
42 | <table class="display"> | |
40 |
|
43 | |||
41 | <tr> |
|
44 | <tr> | |
42 | <td> |
|
45 | <td> | |
43 | ${_ungettext('This repository group includes %s children repository group.', 'This repository group includes %s children repository groups.', c.repo_group.children.count()) % c.repo_group.children.count()} |
|
46 | ${_ungettext('This repository group includes %s children repository group.', 'This repository group includes %s children repository groups.', c.repo_group.children.count()) % c.repo_group.children.count()} | |
44 | </td> |
|
47 | </td> | |
45 | <td> |
|
48 | <td> | |
46 | </td> |
|
49 | </td> | |
47 | <td> |
|
50 | <td> | |
48 | </td> |
|
51 | </td> | |
49 | </tr> |
|
52 | </tr> | |
50 | <tr> |
|
53 | <tr> | |
51 | <td> |
|
54 | <td> | |
52 | ${_ungettext('This repository group includes %s repository.', 'This repository group includes %s repositories.', c.repo_group.repositories_recursive_count) % c.repo_group.repositories_recursive_count} |
|
55 | ${_ungettext('This repository group includes %s repository.', 'This repository group includes %s repositories.', c.repo_group.repositories_recursive_count) % c.repo_group.repositories_recursive_count} | |
53 | </td> |
|
56 | </td> | |
54 | <td> |
|
57 | <td> | |
55 | </td> |
|
58 | </td> | |
56 | <td> |
|
59 | <td> | |
57 | </td> |
|
60 | </td> | |
58 | </tr> |
|
61 | </tr> | |
59 |
|
62 | |||
60 | </table> |
|
63 | </table> | |
61 | <div style="margin: 0 0 20px 0" class="fake-space"></div> |
|
64 | <div style="margin: 0 0 20px 0" class="fake-space"></div> | |
62 |
|
65 | |||
63 | <button class="btn btn-small btn-danger" type="submit" |
|
66 | <button class="btn btn-small btn-danger" type="submit" | |
64 | onclick="return confirm('${_('Confirm to delete this group: %s') % (c.repo_group.group_name)}');"> |
|
67 | onclick="return confirm('${_('Confirm to delete this group: %s') % (c.repo_group.group_name)}');"> | |
65 | ${_('Delete this repository group')} |
|
68 | ${_('Delete this repository group')} | |
66 | </button> |
|
69 | </button> | |
67 | ${h.end_form()} |
|
70 | ${h.end_form()} | |
68 | </div> |
|
71 | </div> | |
69 | </div> |
|
72 | </div> | |
70 |
|
73 | |||
71 |
|
74 |
@@ -1,289 +1,290 b'' | |||||
1 | <%namespace name="base" file="/base/base.mako"/> |
|
1 | <%namespace name="base" file="/base/base.mako"/> | |
2 |
|
2 | |||
3 | <% |
|
3 | <% | |
4 | elems = [ |
|
4 | elems = [ | |
5 | (_('Repository ID'), c.rhodecode_db_repo.repo_id, '', ''), |
|
5 | (_('Repository ID'), c.rhodecode_db_repo.repo_id, '', ''), | |
6 | (_('Owner'), lambda:base.gravatar_with_user(c.rhodecode_db_repo.user.email, tooltip=True), '', ''), |
|
6 | (_('Owner'), lambda:base.gravatar_with_user(c.rhodecode_db_repo.user.email, tooltip=True), '', ''), | |
7 | (_('Created on'), h.format_date(c.rhodecode_db_repo.created_on), '', ''), |
|
7 | (_('Created on'), h.format_date(c.rhodecode_db_repo.created_on), '', ''), | |
8 | (_('Updated on'), h.format_date(c.rhodecode_db_repo.updated_on), '', ''), |
|
8 | (_('Updated on'), h.format_date(c.rhodecode_db_repo.updated_on), '', ''), | |
9 | (_('Cached Commit id'), lambda: h.link_to(c.rhodecode_db_repo.changeset_cache.get('short_id'), h.route_path('repo_commit',repo_name=c.repo_name,commit_id=c.rhodecode_db_repo.changeset_cache.get('raw_id'))), '', ''), |
|
9 | (_('Cached Commit id'), lambda: h.link_to(c.rhodecode_db_repo.changeset_cache.get('short_id'), h.route_path('repo_commit',repo_name=c.repo_name,commit_id=c.rhodecode_db_repo.changeset_cache.get('raw_id'))), '', ''), | |
10 | (_('Cached Commit date'), c.rhodecode_db_repo.changeset_cache.get('date'), '', ''), |
|
10 | (_('Cached Commit date'), c.rhodecode_db_repo.changeset_cache.get('date'), '', ''), | |
|
11 | (_('Cached Commit data'), lambda: h.link_to('refresh now', h.current_route_path(request, update_commit_cache=1)), '', ''), | |||
11 | (_('Attached scoped tokens'), len(c.rhodecode_db_repo.scoped_tokens), '', [x.user for x in c.rhodecode_db_repo.scoped_tokens]), |
|
12 | (_('Attached scoped tokens'), len(c.rhodecode_db_repo.scoped_tokens), '', [x.user for x in c.rhodecode_db_repo.scoped_tokens]), | |
12 | (_('Pull requests source'), len(c.rhodecode_db_repo.pull_requests_source), '', ['pr_id:{}, repo:{}'.format(x.pull_request_id,x.source_repo.repo_name) for x in c.rhodecode_db_repo.pull_requests_source]), |
|
13 | (_('Pull requests source'), len(c.rhodecode_db_repo.pull_requests_source), '', ['pr_id:{}, repo:{}'.format(x.pull_request_id,x.source_repo.repo_name) for x in c.rhodecode_db_repo.pull_requests_source]), | |
13 | (_('Pull requests target'), len(c.rhodecode_db_repo.pull_requests_target), '', ['pr_id:{}, repo:{}'.format(x.pull_request_id,x.target_repo.repo_name) for x in c.rhodecode_db_repo.pull_requests_target]), |
|
14 | (_('Pull requests target'), len(c.rhodecode_db_repo.pull_requests_target), '', ['pr_id:{}, repo:{}'.format(x.pull_request_id,x.target_repo.repo_name) for x in c.rhodecode_db_repo.pull_requests_target]), | |
14 | (_('Attached Artifacts'), len(c.rhodecode_db_repo.artifacts), '', ''), |
|
15 | (_('Attached Artifacts'), len(c.rhodecode_db_repo.artifacts), '', ''), | |
15 | ] |
|
16 | ] | |
16 | %> |
|
17 | %> | |
17 |
|
18 | |||
18 | <div class="panel panel-default"> |
|
19 | <div class="panel panel-default"> | |
19 | <div class="panel-heading" id="advanced-info" > |
|
20 | <div class="panel-heading" id="advanced-info" > | |
20 | <h3 class="panel-title">${_('Repository: %s') % c.rhodecode_db_repo.repo_name} <a class="permalink" href="#advanced-info"> ΒΆ</a></h3> |
|
21 | <h3 class="panel-title">${_('Repository: %s') % c.rhodecode_db_repo.repo_name} <a class="permalink" href="#advanced-info"> ΒΆ</a></h3> | |
21 | </div> |
|
22 | </div> | |
22 | <div class="panel-body"> |
|
23 | <div class="panel-body"> | |
23 | ${base.dt_info_panel(elems)} |
|
24 | ${base.dt_info_panel(elems)} | |
24 | </div> |
|
25 | </div> | |
25 | </div> |
|
26 | </div> | |
26 |
|
27 | |||
27 |
|
28 | |||
28 | <div class="panel panel-default"> |
|
29 | <div class="panel panel-default"> | |
29 | <div class="panel-heading" id="advanced-fork"> |
|
30 | <div class="panel-heading" id="advanced-fork"> | |
30 | <h3 class="panel-title">${_('Fork Reference')} <a class="permalink" href="#advanced-fork"> ΒΆ</a></h3> |
|
31 | <h3 class="panel-title">${_('Fork Reference')} <a class="permalink" href="#advanced-fork"> ΒΆ</a></h3> | |
31 | </div> |
|
32 | </div> | |
32 | <div class="panel-body"> |
|
33 | <div class="panel-body"> | |
33 | ${h.secure_form(h.route_path('edit_repo_advanced_fork', repo_name=c.rhodecode_db_repo.repo_name), request=request)} |
|
34 | ${h.secure_form(h.route_path('edit_repo_advanced_fork', repo_name=c.rhodecode_db_repo.repo_name), request=request)} | |
34 |
|
35 | |||
35 | % if c.rhodecode_db_repo.fork: |
|
36 | % if c.rhodecode_db_repo.fork: | |
36 | <div class="panel-body-title-text">${h.literal(_('This repository is a fork of %(repo_link)s') % {'repo_link': h.link_to_if(c.has_origin_repo_read_perm,c.rhodecode_db_repo.fork.repo_name, h.route_path('repo_summary', repo_name=c.rhodecode_db_repo.fork.repo_name))})} |
|
37 | <div class="panel-body-title-text">${h.literal(_('This repository is a fork of %(repo_link)s') % {'repo_link': h.link_to_if(c.has_origin_repo_read_perm,c.rhodecode_db_repo.fork.repo_name, h.route_path('repo_summary', repo_name=c.rhodecode_db_repo.fork.repo_name))})} | |
37 | | <button class="btn btn-link btn-danger" type="submit">Remove fork reference</button></div> |
|
38 | | <button class="btn btn-link btn-danger" type="submit">Remove fork reference</button></div> | |
38 | % endif |
|
39 | % endif | |
39 |
|
40 | |||
40 | <div class="field"> |
|
41 | <div class="field"> | |
41 | ${h.hidden('id_fork_of')} |
|
42 | ${h.hidden('id_fork_of')} | |
42 | ${h.submit('set_as_fork_%s' % c.rhodecode_db_repo.repo_name,_('Set'),class_="btn btn-small",)} |
|
43 | ${h.submit('set_as_fork_%s' % c.rhodecode_db_repo.repo_name,_('Set'),class_="btn btn-small",)} | |
43 | </div> |
|
44 | </div> | |
44 | <div class="field"> |
|
45 | <div class="field"> | |
45 | <span class="help-block">${_('Manually set this repository as a fork of another from the list')}</span> |
|
46 | <span class="help-block">${_('Manually set this repository as a fork of another from the list')}</span> | |
46 | </div> |
|
47 | </div> | |
47 | ${h.end_form()} |
|
48 | ${h.end_form()} | |
48 | </div> |
|
49 | </div> | |
49 | </div> |
|
50 | </div> | |
50 |
|
51 | |||
51 |
|
52 | |||
52 | <div class="panel panel-default"> |
|
53 | <div class="panel panel-default"> | |
53 | <div class="panel-heading" id="advanced-journal"> |
|
54 | <div class="panel-heading" id="advanced-journal"> | |
54 | <h3 class="panel-title">${_('Public Journal Visibility')} <a class="permalink" href="#advanced-journal"> ΒΆ</a></h3> |
|
55 | <h3 class="panel-title">${_('Public Journal Visibility')} <a class="permalink" href="#advanced-journal"> ΒΆ</a></h3> | |
55 | </div> |
|
56 | </div> | |
56 | <div class="panel-body"> |
|
57 | <div class="panel-body"> | |
57 | ${h.secure_form(h.route_path('edit_repo_advanced_journal', repo_name=c.rhodecode_db_repo.repo_name), request=request)} |
|
58 | ${h.secure_form(h.route_path('edit_repo_advanced_journal', repo_name=c.rhodecode_db_repo.repo_name), request=request)} | |
58 | <div class="field"> |
|
59 | <div class="field"> | |
59 | %if c.in_public_journal: |
|
60 | %if c.in_public_journal: | |
60 | <button class="btn btn-small" type="submit"> |
|
61 | <button class="btn btn-small" type="submit"> | |
61 | ${_('Remove from Public Journal')} |
|
62 | ${_('Remove from Public Journal')} | |
62 | </button> |
|
63 | </button> | |
63 | %else: |
|
64 | %else: | |
64 | <button class="btn btn-small" type="submit"> |
|
65 | <button class="btn btn-small" type="submit"> | |
65 | ${_('Add to Public Journal')} |
|
66 | ${_('Add to Public Journal')} | |
66 | </button> |
|
67 | </button> | |
67 | %endif |
|
68 | %endif | |
68 | </div> |
|
69 | </div> | |
69 | <div class="field" > |
|
70 | <div class="field" > | |
70 | <span class="help-block">${_('All actions made on this repository will be visible to everyone following the public journal.')}</span> |
|
71 | <span class="help-block">${_('All actions made on this repository will be visible to everyone following the public journal.')}</span> | |
71 | </div> |
|
72 | </div> | |
72 | ${h.end_form()} |
|
73 | ${h.end_form()} | |
73 | </div> |
|
74 | </div> | |
74 | </div> |
|
75 | </div> | |
75 |
|
76 | |||
76 |
|
77 | |||
77 | <div class="panel panel-default"> |
|
78 | <div class="panel panel-default"> | |
78 | <div class="panel-heading" id="advanced-locking"> |
|
79 | <div class="panel-heading" id="advanced-locking"> | |
79 | <h3 class="panel-title">${_('Locking state')} <a class="permalink" href="#advanced-locking"> ΒΆ</a></h3> |
|
80 | <h3 class="panel-title">${_('Locking state')} <a class="permalink" href="#advanced-locking"> ΒΆ</a></h3> | |
80 | </div> |
|
81 | </div> | |
81 | <div class="panel-body"> |
|
82 | <div class="panel-body"> | |
82 | ${h.secure_form(h.route_path('edit_repo_advanced_locking', repo_name=c.rhodecode_db_repo.repo_name), request=request)} |
|
83 | ${h.secure_form(h.route_path('edit_repo_advanced_locking', repo_name=c.rhodecode_db_repo.repo_name), request=request)} | |
83 |
|
84 | |||
84 | %if c.rhodecode_db_repo.locked[0]: |
|
85 | %if c.rhodecode_db_repo.locked[0]: | |
85 | <div class="panel-body-title-text">${'Locked by %s on %s. Lock reason: %s' % (h.person_by_id(c.rhodecode_db_repo.locked[0]), |
|
86 | <div class="panel-body-title-text">${'Locked by %s on %s. Lock reason: %s' % (h.person_by_id(c.rhodecode_db_repo.locked[0]), | |
86 | h.format_date(h. time_to_datetime(c.rhodecode_db_repo.locked[1])), c.rhodecode_db_repo.locked[2])}</div> |
|
87 | h.format_date(h. time_to_datetime(c.rhodecode_db_repo.locked[1])), c.rhodecode_db_repo.locked[2])}</div> | |
87 | %else: |
|
88 | %else: | |
88 | <div class="panel-body-title-text">${_('This Repository is not currently locked.')}</div> |
|
89 | <div class="panel-body-title-text">${_('This Repository is not currently locked.')}</div> | |
89 | %endif |
|
90 | %endif | |
90 |
|
91 | |||
91 | <div class="field" > |
|
92 | <div class="field" > | |
92 | %if c.rhodecode_db_repo.locked[0]: |
|
93 | %if c.rhodecode_db_repo.locked[0]: | |
93 | ${h.hidden('set_unlock', '1')} |
|
94 | ${h.hidden('set_unlock', '1')} | |
94 | <button class="btn btn-small" type="submit" |
|
95 | <button class="btn btn-small" type="submit" | |
95 | onclick="return confirm('${_('Confirm to unlock repository.')}');"> |
|
96 | onclick="return confirm('${_('Confirm to unlock repository.')}');"> | |
96 | <i class="icon-unlock"></i> |
|
97 | <i class="icon-unlock"></i> | |
97 | ${_('Unlock repository')} |
|
98 | ${_('Unlock repository')} | |
98 | </button> |
|
99 | </button> | |
99 | %else: |
|
100 | %else: | |
100 | ${h.hidden('set_lock', '1')} |
|
101 | ${h.hidden('set_lock', '1')} | |
101 | <button class="btn btn-small" type="submit" |
|
102 | <button class="btn btn-small" type="submit" | |
102 | onclick="return confirm('${_('Confirm to lock repository.')}');"> |
|
103 | onclick="return confirm('${_('Confirm to lock repository.')}');"> | |
103 | <i class="icon-lock"></i> |
|
104 | <i class="icon-lock"></i> | |
104 | ${_('Lock repository')} |
|
105 | ${_('Lock repository')} | |
105 | </button> |
|
106 | </button> | |
106 | %endif |
|
107 | %endif | |
107 | </div> |
|
108 | </div> | |
108 | <div class="field" > |
|
109 | <div class="field" > | |
109 | <span class="help-block"> |
|
110 | <span class="help-block"> | |
110 | ${_('Force repository locking. This only works when anonymous access is disabled. Pulling from the repository locks the repository to that user until the same user pushes to that repository again.')} |
|
111 | ${_('Force repository locking. This only works when anonymous access is disabled. Pulling from the repository locks the repository to that user until the same user pushes to that repository again.')} | |
111 | </span> |
|
112 | </span> | |
112 | </div> |
|
113 | </div> | |
113 | ${h.end_form()} |
|
114 | ${h.end_form()} | |
114 | </div> |
|
115 | </div> | |
115 | </div> |
|
116 | </div> | |
116 |
|
117 | |||
117 |
|
118 | |||
118 | <div class="panel panel-default"> |
|
119 | <div class="panel panel-default"> | |
119 | <div class="panel-heading" id="advanced-hooks"> |
|
120 | <div class="panel-heading" id="advanced-hooks"> | |
120 | <h3 class="panel-title">${_('Hooks')} <a class="permalink" href="#advanced-hooks"> ΒΆ</a></h3> |
|
121 | <h3 class="panel-title">${_('Hooks')} <a class="permalink" href="#advanced-hooks"> ΒΆ</a></h3> | |
121 | </div> |
|
122 | </div> | |
122 | <div class="panel-body"> |
|
123 | <div class="panel-body"> | |
123 | <table class="rctable"> |
|
124 | <table class="rctable"> | |
124 | <th>${_('Hook type')}</th> |
|
125 | <th>${_('Hook type')}</th> | |
125 | <th>${_('Hook version')}</th> |
|
126 | <th>${_('Hook version')}</th> | |
126 | <th>${_('Current version')}</th> |
|
127 | <th>${_('Current version')}</th> | |
127 | % if c.ver_info_dict: |
|
128 | % if c.ver_info_dict: | |
128 | <tr> |
|
129 | <tr> | |
129 | <td>${_('PRE HOOK')}</td> |
|
130 | <td>${_('PRE HOOK')}</td> | |
130 | <td>${c.ver_info_dict['pre_version']}</td> |
|
131 | <td>${c.ver_info_dict['pre_version']}</td> | |
131 | <td>${c.rhodecode_version}</td> |
|
132 | <td>${c.rhodecode_version}</td> | |
132 | </tr> |
|
133 | </tr> | |
133 | <tr> |
|
134 | <tr> | |
134 | <td>${_('POST HOOK')}</td> |
|
135 | <td>${_('POST HOOK')}</td> | |
135 | <td>${c.ver_info_dict['post_version']}</td> |
|
136 | <td>${c.ver_info_dict['post_version']}</td> | |
136 | <td>${c.rhodecode_version}</td> |
|
137 | <td>${c.rhodecode_version}</td> | |
137 | </tr> |
|
138 | </tr> | |
138 | % else: |
|
139 | % else: | |
139 | <tr> |
|
140 | <tr> | |
140 | <td>${_('Unable to read hook information from VCS Server')}</td> |
|
141 | <td>${_('Unable to read hook information from VCS Server')}</td> | |
141 | </tr> |
|
142 | </tr> | |
142 | % endif |
|
143 | % endif | |
143 | </table> |
|
144 | </table> | |
144 |
|
145 | |||
145 | <a class="btn btn-primary" href="${h.route_path('edit_repo_advanced_hooks', repo_name=c.repo_name)}" |
|
146 | <a class="btn btn-primary" href="${h.route_path('edit_repo_advanced_hooks', repo_name=c.repo_name)}" | |
146 | onclick="return confirm('${_('Confirm to reinstall hooks for this repository.')}');"> |
|
147 | onclick="return confirm('${_('Confirm to reinstall hooks for this repository.')}');"> | |
147 | ${_('Update Hooks')} |
|
148 | ${_('Update Hooks')} | |
148 | </a> |
|
149 | </a> | |
149 | </div> |
|
150 | </div> | |
150 | </div> |
|
151 | </div> | |
151 |
|
152 | |||
152 | <div class="panel panel-warning"> |
|
153 | <div class="panel panel-warning"> | |
153 | <div class="panel-heading" id="advanced-archive"> |
|
154 | <div class="panel-heading" id="advanced-archive"> | |
154 | <h3 class="panel-title">${_('Archive repository')} <a class="permalink" href="#advanced-archive"> ΒΆ</a></h3> |
|
155 | <h3 class="panel-title">${_('Archive repository')} <a class="permalink" href="#advanced-archive"> ΒΆ</a></h3> | |
155 | </div> |
|
156 | </div> | |
156 | <div class="panel-body"> |
|
157 | <div class="panel-body"> | |
157 | ${h.secure_form(h.route_path('edit_repo_advanced_archive', repo_name=c.repo_name), request=request)} |
|
158 | ${h.secure_form(h.route_path('edit_repo_advanced_archive', repo_name=c.repo_name), request=request)} | |
158 |
|
159 | |||
159 | <div style="margin: 0 0 20px 0" class="fake-space"></div> |
|
160 | <div style="margin: 0 0 20px 0" class="fake-space"></div> | |
160 |
|
161 | |||
161 | <div class="field"> |
|
162 | <div class="field"> | |
162 | <button class="btn btn-small btn-warning" type="submit" |
|
163 | <button class="btn btn-small btn-warning" type="submit" | |
163 | onclick="return confirm('${_('Confirm to archive this repository: %s') % c.repo_name}');"> |
|
164 | onclick="return confirm('${_('Confirm to archive this repository: %s') % c.repo_name}');"> | |
164 | ${_('Archive this repository')} |
|
165 | ${_('Archive this repository')} | |
165 | </button> |
|
166 | </button> | |
166 | </div> |
|
167 | </div> | |
167 | <div class="field"> |
|
168 | <div class="field"> | |
168 | <span class="help-block"> |
|
169 | <span class="help-block"> | |
169 | ${_('Archiving the repository will make it entirely read-only. The repository cannot be committed to.' |
|
170 | ${_('Archiving the repository will make it entirely read-only. The repository cannot be committed to.' | |
170 | 'It is hidden from the search results and dashboard. ')} |
|
171 | 'It is hidden from the search results and dashboard. ')} | |
171 | </span> |
|
172 | </span> | |
172 | </div> |
|
173 | </div> | |
173 |
|
174 | |||
174 | ${h.end_form()} |
|
175 | ${h.end_form()} | |
175 | </div> |
|
176 | </div> | |
176 | </div> |
|
177 | </div> | |
177 |
|
178 | |||
178 |
|
179 | |||
179 | <div class="panel panel-danger"> |
|
180 | <div class="panel panel-danger"> | |
180 | <div class="panel-heading" id="advanced-delete"> |
|
181 | <div class="panel-heading" id="advanced-delete"> | |
181 | <h3 class="panel-title">${_('Delete repository')} <a class="permalink" href="#advanced-delete"> ΒΆ</a></h3> |
|
182 | <h3 class="panel-title">${_('Delete repository')} <a class="permalink" href="#advanced-delete"> ΒΆ</a></h3> | |
182 | </div> |
|
183 | </div> | |
183 | <div class="panel-body"> |
|
184 | <div class="panel-body"> | |
184 | ${h.secure_form(h.route_path('edit_repo_advanced_delete', repo_name=c.repo_name), request=request)} |
|
185 | ${h.secure_form(h.route_path('edit_repo_advanced_delete', repo_name=c.repo_name), request=request)} | |
185 | <table class="display"> |
|
186 | <table class="display"> | |
186 | <tr> |
|
187 | <tr> | |
187 | <td> |
|
188 | <td> | |
188 | ${_ungettext('This repository has %s fork.', 'This repository has %s forks.', c.rhodecode_db_repo.forks.count()) % c.rhodecode_db_repo.forks.count()} |
|
189 | ${_ungettext('This repository has %s fork.', 'This repository has %s forks.', c.rhodecode_db_repo.forks.count()) % c.rhodecode_db_repo.forks.count()} | |
189 | </td> |
|
190 | </td> | |
190 | <td> |
|
191 | <td> | |
191 | %if c.rhodecode_db_repo.forks.count(): |
|
192 | %if c.rhodecode_db_repo.forks.count(): | |
192 | <input type="radio" name="forks" value="detach_forks" checked="checked"/> <label for="forks">${_('Detach forks')}</label> |
|
193 | <input type="radio" name="forks" value="detach_forks" checked="checked"/> <label for="forks">${_('Detach forks')}</label> | |
193 | %endif |
|
194 | %endif | |
194 | </td> |
|
195 | </td> | |
195 | <td> |
|
196 | <td> | |
196 | %if c.rhodecode_db_repo.forks.count(): |
|
197 | %if c.rhodecode_db_repo.forks.count(): | |
197 | <input type="radio" name="forks" value="delete_forks"/> <label for="forks">${_('Delete forks')}</label> |
|
198 | <input type="radio" name="forks" value="delete_forks"/> <label for="forks">${_('Delete forks')}</label> | |
198 | %endif |
|
199 | %endif | |
199 | </td> |
|
200 | </td> | |
200 | </tr> |
|
201 | </tr> | |
201 | <% attached_prs = len(c.rhodecode_db_repo.pull_requests_source + c.rhodecode_db_repo.pull_requests_target) %> |
|
202 | <% attached_prs = len(c.rhodecode_db_repo.pull_requests_source + c.rhodecode_db_repo.pull_requests_target) %> | |
202 | % if c.rhodecode_db_repo.pull_requests_source or c.rhodecode_db_repo.pull_requests_target: |
|
203 | % if c.rhodecode_db_repo.pull_requests_source or c.rhodecode_db_repo.pull_requests_target: | |
203 | <tr> |
|
204 | <tr> | |
204 | <td> |
|
205 | <td> | |
205 | ${_ungettext('This repository has %s attached pull request.', 'This repository has %s attached pull requests.', attached_prs) % attached_prs} |
|
206 | ${_ungettext('This repository has %s attached pull request.', 'This repository has %s attached pull requests.', attached_prs) % attached_prs} | |
206 | <br/> |
|
207 | <br/> | |
207 | ${_('Consider to archive this repository instead.')} |
|
208 | ${_('Consider to archive this repository instead.')} | |
208 | </td> |
|
209 | </td> | |
209 | <td></td> |
|
210 | <td></td> | |
210 | <td></td> |
|
211 | <td></td> | |
211 | </tr> |
|
212 | </tr> | |
212 | % endif |
|
213 | % endif | |
213 | </table> |
|
214 | </table> | |
214 | <div style="margin: 0 0 20px 0" class="fake-space"></div> |
|
215 | <div style="margin: 0 0 20px 0" class="fake-space"></div> | |
215 |
|
216 | |||
216 | <div class="field"> |
|
217 | <div class="field"> | |
217 | <button class="btn btn-small btn-danger" type="submit" |
|
218 | <button class="btn btn-small btn-danger" type="submit" | |
218 | onclick="return confirm('${_('Confirm to delete this repository: %s') % c.repo_name}');"> |
|
219 | onclick="return confirm('${_('Confirm to delete this repository: %s') % c.repo_name}');"> | |
219 | ${_('Delete this repository')} |
|
220 | ${_('Delete this repository')} | |
220 | </button> |
|
221 | </button> | |
221 | </div> |
|
222 | </div> | |
222 | <div class="field"> |
|
223 | <div class="field"> | |
223 | <span class="help-block"> |
|
224 | <span class="help-block"> | |
224 | ${_('This repository will be renamed in a special way in order to make it inaccessible to RhodeCode Enterprise and its VCS systems. If you need to fully delete it from the file system, please do it manually, or with rhodecode-cleanup-repos command available in rhodecode-tools.')} |
|
225 | ${_('This repository will be renamed in a special way in order to make it inaccessible to RhodeCode Enterprise and its VCS systems. If you need to fully delete it from the file system, please do it manually, or with rhodecode-cleanup-repos command available in rhodecode-tools.')} | |
225 | </span> |
|
226 | </span> | |
226 | </div> |
|
227 | </div> | |
227 |
|
228 | |||
228 | ${h.end_form()} |
|
229 | ${h.end_form()} | |
229 | </div> |
|
230 | </div> | |
230 | </div> |
|
231 | </div> | |
231 |
|
232 | |||
232 |
|
233 | |||
233 | <script> |
|
234 | <script> | |
234 |
|
235 | |||
235 | var currentRepoId = ${c.rhodecode_db_repo.repo_id}; |
|
236 | var currentRepoId = ${c.rhodecode_db_repo.repo_id}; | |
236 |
|
237 | |||
237 | var repoTypeFilter = function(data) { |
|
238 | var repoTypeFilter = function(data) { | |
238 | var results = []; |
|
239 | var results = []; | |
239 |
|
240 | |||
240 | if (!data.results[0]) { |
|
241 | if (!data.results[0]) { | |
241 | return data |
|
242 | return data | |
242 | } |
|
243 | } | |
243 |
|
244 | |||
244 | $.each(data.results[0].children, function() { |
|
245 | $.each(data.results[0].children, function() { | |
245 | // filter out the SAME repo, it cannot be used as fork of itself |
|
246 | // filter out the SAME repo, it cannot be used as fork of itself | |
246 | if (this.repo_id != currentRepoId) { |
|
247 | if (this.repo_id != currentRepoId) { | |
247 | this.id = this.repo_id; |
|
248 | this.id = this.repo_id; | |
248 | results.push(this) |
|
249 | results.push(this) | |
249 | } |
|
250 | } | |
250 | }); |
|
251 | }); | |
251 | data.results[0].children = results; |
|
252 | data.results[0].children = results; | |
252 | return data; |
|
253 | return data; | |
253 | }; |
|
254 | }; | |
254 |
|
255 | |||
255 | $("#id_fork_of").select2({ |
|
256 | $("#id_fork_of").select2({ | |
256 | cachedDataSource: {}, |
|
257 | cachedDataSource: {}, | |
257 | minimumInputLength: 2, |
|
258 | minimumInputLength: 2, | |
258 | placeholder: "${_('Change repository') if c.rhodecode_db_repo.fork else _('Pick repository')}", |
|
259 | placeholder: "${_('Change repository') if c.rhodecode_db_repo.fork else _('Pick repository')}", | |
259 | dropdownAutoWidth: true, |
|
260 | dropdownAutoWidth: true, | |
260 | containerCssClass: "drop-menu", |
|
261 | containerCssClass: "drop-menu", | |
261 | dropdownCssClass: "drop-menu-dropdown", |
|
262 | dropdownCssClass: "drop-menu-dropdown", | |
262 | formatResult: formatRepoResult, |
|
263 | formatResult: formatRepoResult, | |
263 | query: $.debounce(250, function(query){ |
|
264 | query: $.debounce(250, function(query){ | |
264 | self = this; |
|
265 | self = this; | |
265 | var cacheKey = query.term; |
|
266 | var cacheKey = query.term; | |
266 | var cachedData = self.cachedDataSource[cacheKey]; |
|
267 | var cachedData = self.cachedDataSource[cacheKey]; | |
267 |
|
268 | |||
268 | if (cachedData) { |
|
269 | if (cachedData) { | |
269 | query.callback({results: cachedData.results}); |
|
270 | query.callback({results: cachedData.results}); | |
270 | } else { |
|
271 | } else { | |
271 | $.ajax({ |
|
272 | $.ajax({ | |
272 | url: pyroutes.url('repo_list_data'), |
|
273 | url: pyroutes.url('repo_list_data'), | |
273 | data: {'query': query.term, repo_type: '${c.rhodecode_db_repo.repo_type}'}, |
|
274 | data: {'query': query.term, repo_type: '${c.rhodecode_db_repo.repo_type}'}, | |
274 | dataType: 'json', |
|
275 | dataType: 'json', | |
275 | type: 'GET', |
|
276 | type: 'GET', | |
276 | success: function(data) { |
|
277 | success: function(data) { | |
277 | data = repoTypeFilter(data); |
|
278 | data = repoTypeFilter(data); | |
278 | self.cachedDataSource[cacheKey] = data; |
|
279 | self.cachedDataSource[cacheKey] = data; | |
279 | query.callback({results: data.results}); |
|
280 | query.callback({results: data.results}); | |
280 | }, |
|
281 | }, | |
281 | error: function(data, textStatus, errorThrown) { |
|
282 | error: function(data, textStatus, errorThrown) { | |
282 | alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText)); |
|
283 | alert("Error while fetching entries.\nError code {0} ({1}).".format(data.status, data.statusText)); | |
283 | } |
|
284 | } | |
284 | }) |
|
285 | }) | |
285 | } |
|
286 | } | |
286 | }) |
|
287 | }) | |
287 | }); |
|
288 | }); | |
288 | </script> |
|
289 | </script> | |
289 |
|
290 |
General Comments 0
You need to be logged in to leave comments.
Login now