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