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