##// END OF EJS Templates
tests: fixed repo tests after changes for repo type selector.
marcink -
r4330:d9a14621 default
parent child Browse files
Show More
@@ -1,514 +1,512 b''
1 1 # -*- coding: utf-8 -*-
2 2
3 3 # Copyright (C) 2010-2020 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 urllib
22 22
23 23 import mock
24 24 import pytest
25 25
26 26 from rhodecode.apps._base import ADMIN_PREFIX
27 27 from rhodecode.lib import auth
28 28 from rhodecode.lib.utils2 import safe_str
29 29 from rhodecode.lib import helpers as h
30 30 from rhodecode.model.db import (
31 31 Repository, RepoGroup, UserRepoToPerm, User, Permission)
32 32 from rhodecode.model.meta import Session
33 33 from rhodecode.model.repo import RepoModel
34 34 from rhodecode.model.repo_group import RepoGroupModel
35 35 from rhodecode.model.user import UserModel
36 36 from rhodecode.tests import (
37 37 login_user_session, assert_session_flash, TEST_USER_ADMIN_LOGIN,
38 38 TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS)
39 39 from rhodecode.tests.fixture import Fixture, error_function
40 40 from rhodecode.tests.utils import AssertResponse, repo_on_filesystem
41 41
42 42 fixture = Fixture()
43 43
44 44
45 45 def route_path(name, params=None, **kwargs):
46 46 import urllib
47 47
48 48 base_url = {
49 49 'repos': ADMIN_PREFIX + '/repos',
50 50 'repos_data': ADMIN_PREFIX + '/repos_data',
51 51 'repo_new': ADMIN_PREFIX + '/repos/new',
52 52 'repo_create': ADMIN_PREFIX + '/repos/create',
53 53
54 54 'repo_creating_check': '/{repo_name}/repo_creating_check',
55 55 }[name].format(**kwargs)
56 56
57 57 if params:
58 58 base_url = '{}?{}'.format(base_url, urllib.urlencode(params))
59 59 return base_url
60 60
61 61
62 62 def _get_permission_for_user(user, repo):
63 63 perm = UserRepoToPerm.query()\
64 64 .filter(UserRepoToPerm.repository ==
65 65 Repository.get_by_repo_name(repo))\
66 66 .filter(UserRepoToPerm.user == User.get_by_username(user))\
67 67 .all()
68 68 return perm
69 69
70 70
71 71 @pytest.mark.usefixtures("app")
72 72 class TestAdminRepos(object):
73 73
74 74 def test_repo_list(self, autologin_user, user_util, xhr_header):
75 75 repo = user_util.create_repo()
76 76 repo_name = repo.repo_name
77 77 response = self.app.get(
78 78 route_path('repos_data'), status=200,
79 79 extra_environ=xhr_header)
80 80
81 81 response.mustcontain(repo_name)
82 82
83 83 def test_create_page_restricted_to_single_backend(self, autologin_user, backend):
84 84 with mock.patch('rhodecode.BACKENDS', {'git': 'git'}):
85 85 response = self.app.get(route_path('repo_new'), status=200)
86 86 assert_response = response.assert_response()
87 element = assert_response.get_element('#repo_type')
88 assert element.text_content() == '\ngit\n'
87 element = assert_response.get_element('[name=repo_type]')
88 assert element.get('value') == 'git'
89 89
90 90 def test_create_page_non_restricted_backends(self, autologin_user, backend):
91 91 response = self.app.get(route_path('repo_new'), status=200)
92 92 assert_response = response.assert_response()
93 assert_response.element_contains('#repo_type', 'git')
94 assert_response.element_contains('#repo_type', 'svn')
95 assert_response.element_contains('#repo_type', 'hg')
93 assert ['hg', 'git', 'svn'] == [x.get('value') for x in assert_response.get_elements('[name=repo_type]')]
96 94
97 95 @pytest.mark.parametrize(
98 96 "suffix", [u'', u'xxa'], ids=['', 'non-ascii'])
99 97 def test_create(self, autologin_user, backend, suffix, csrf_token):
100 98 repo_name_unicode = backend.new_repo_name(suffix=suffix)
101 99 repo_name = repo_name_unicode.encode('utf8')
102 100 description_unicode = u'description for newly created repo' + suffix
103 101 description = description_unicode.encode('utf8')
104 102 response = self.app.post(
105 103 route_path('repo_create'),
106 104 fixture._get_repo_create_params(
107 105 repo_private=False,
108 106 repo_name=repo_name,
109 107 repo_type=backend.alias,
110 108 repo_description=description,
111 109 csrf_token=csrf_token),
112 110 status=302)
113 111
114 112 self.assert_repository_is_created_correctly(
115 113 repo_name, description, backend)
116 114
117 115 def test_create_numeric_name(self, autologin_user, backend, csrf_token):
118 116 numeric_repo = '1234'
119 117 repo_name = numeric_repo
120 118 description = 'description for newly created repo' + numeric_repo
121 119 self.app.post(
122 120 route_path('repo_create'),
123 121 fixture._get_repo_create_params(
124 122 repo_private=False,
125 123 repo_name=repo_name,
126 124 repo_type=backend.alias,
127 125 repo_description=description,
128 126 csrf_token=csrf_token))
129 127
130 128 self.assert_repository_is_created_correctly(
131 129 repo_name, description, backend)
132 130
133 131 @pytest.mark.parametrize("suffix", [u'', u'Δ…Δ‡Δ™'], ids=['', 'non-ascii'])
134 132 def test_create_in_group(
135 133 self, autologin_user, backend, suffix, csrf_token):
136 134 # create GROUP
137 135 group_name = 'sometest_%s' % backend.alias
138 136 gr = RepoGroupModel().create(group_name=group_name,
139 137 group_description='test',
140 138 owner=TEST_USER_ADMIN_LOGIN)
141 139 Session().commit()
142 140
143 141 repo_name = u'ingroup' + suffix
144 142 repo_name_full = RepoGroup.url_sep().join(
145 143 [group_name, repo_name])
146 144 description = u'description for newly created repo'
147 145 self.app.post(
148 146 route_path('repo_create'),
149 147 fixture._get_repo_create_params(
150 148 repo_private=False,
151 149 repo_name=safe_str(repo_name),
152 150 repo_type=backend.alias,
153 151 repo_description=description,
154 152 repo_group=gr.group_id,
155 153 csrf_token=csrf_token))
156 154
157 155 # TODO: johbo: Cleanup work to fixture
158 156 try:
159 157 self.assert_repository_is_created_correctly(
160 158 repo_name_full, description, backend)
161 159
162 160 new_repo = RepoModel().get_by_repo_name(repo_name_full)
163 161 inherited_perms = UserRepoToPerm.query().filter(
164 162 UserRepoToPerm.repository_id == new_repo.repo_id).all()
165 163 assert len(inherited_perms) == 1
166 164 finally:
167 165 RepoModel().delete(repo_name_full)
168 166 RepoGroupModel().delete(group_name)
169 167 Session().commit()
170 168
171 169 def test_create_in_group_numeric_name(
172 170 self, autologin_user, backend, csrf_token):
173 171 # create GROUP
174 172 group_name = 'sometest_%s' % backend.alias
175 173 gr = RepoGroupModel().create(group_name=group_name,
176 174 group_description='test',
177 175 owner=TEST_USER_ADMIN_LOGIN)
178 176 Session().commit()
179 177
180 178 repo_name = '12345'
181 179 repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
182 180 description = 'description for newly created repo'
183 181 self.app.post(
184 182 route_path('repo_create'),
185 183 fixture._get_repo_create_params(
186 184 repo_private=False,
187 185 repo_name=repo_name,
188 186 repo_type=backend.alias,
189 187 repo_description=description,
190 188 repo_group=gr.group_id,
191 189 csrf_token=csrf_token))
192 190
193 191 # TODO: johbo: Cleanup work to fixture
194 192 try:
195 193 self.assert_repository_is_created_correctly(
196 194 repo_name_full, description, backend)
197 195
198 196 new_repo = RepoModel().get_by_repo_name(repo_name_full)
199 197 inherited_perms = UserRepoToPerm.query()\
200 198 .filter(UserRepoToPerm.repository_id == new_repo.repo_id).all()
201 199 assert len(inherited_perms) == 1
202 200 finally:
203 201 RepoModel().delete(repo_name_full)
204 202 RepoGroupModel().delete(group_name)
205 203 Session().commit()
206 204
207 205 def test_create_in_group_without_needed_permissions(self, backend):
208 206 session = login_user_session(
209 207 self.app, TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS)
210 208 csrf_token = auth.get_csrf_token(session)
211 209 # revoke
212 210 user_model = UserModel()
213 211 # disable fork and create on default user
214 212 user_model.revoke_perm(User.DEFAULT_USER, 'hg.create.repository')
215 213 user_model.grant_perm(User.DEFAULT_USER, 'hg.create.none')
216 214 user_model.revoke_perm(User.DEFAULT_USER, 'hg.fork.repository')
217 215 user_model.grant_perm(User.DEFAULT_USER, 'hg.fork.none')
218 216
219 217 # disable on regular user
220 218 user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.repository')
221 219 user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.none')
222 220 user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.repository')
223 221 user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.none')
224 222 Session().commit()
225 223
226 224 # create GROUP
227 225 group_name = 'reg_sometest_%s' % backend.alias
228 226 gr = RepoGroupModel().create(group_name=group_name,
229 227 group_description='test',
230 228 owner=TEST_USER_ADMIN_LOGIN)
231 229 Session().commit()
232 230 repo_group_id = gr.group_id
233 231
234 232 group_name_allowed = 'reg_sometest_allowed_%s' % backend.alias
235 233 gr_allowed = RepoGroupModel().create(
236 234 group_name=group_name_allowed,
237 235 group_description='test',
238 236 owner=TEST_USER_REGULAR_LOGIN)
239 237 allowed_repo_group_id = gr_allowed.group_id
240 238 Session().commit()
241 239
242 240 repo_name = 'ingroup'
243 241 description = 'description for newly created repo'
244 242 response = self.app.post(
245 243 route_path('repo_create'),
246 244 fixture._get_repo_create_params(
247 245 repo_private=False,
248 246 repo_name=repo_name,
249 247 repo_type=backend.alias,
250 248 repo_description=description,
251 249 repo_group=repo_group_id,
252 250 csrf_token=csrf_token))
253 251
254 252 response.mustcontain('Invalid value')
255 253
256 254 # user is allowed to create in this group
257 255 repo_name = 'ingroup'
258 256 repo_name_full = RepoGroup.url_sep().join(
259 257 [group_name_allowed, repo_name])
260 258 description = 'description for newly created repo'
261 259 response = self.app.post(
262 260 route_path('repo_create'),
263 261 fixture._get_repo_create_params(
264 262 repo_private=False,
265 263 repo_name=repo_name,
266 264 repo_type=backend.alias,
267 265 repo_description=description,
268 266 repo_group=allowed_repo_group_id,
269 267 csrf_token=csrf_token))
270 268
271 269 # TODO: johbo: Cleanup in pytest fixture
272 270 try:
273 271 self.assert_repository_is_created_correctly(
274 272 repo_name_full, description, backend)
275 273
276 274 new_repo = RepoModel().get_by_repo_name(repo_name_full)
277 275 inherited_perms = UserRepoToPerm.query().filter(
278 276 UserRepoToPerm.repository_id == new_repo.repo_id).all()
279 277 assert len(inherited_perms) == 1
280 278
281 279 assert repo_on_filesystem(repo_name_full)
282 280 finally:
283 281 RepoModel().delete(repo_name_full)
284 282 RepoGroupModel().delete(group_name)
285 283 RepoGroupModel().delete(group_name_allowed)
286 284 Session().commit()
287 285
288 286 def test_create_in_group_inherit_permissions(self, autologin_user, backend,
289 287 csrf_token):
290 288 # create GROUP
291 289 group_name = 'sometest_%s' % backend.alias
292 290 gr = RepoGroupModel().create(group_name=group_name,
293 291 group_description='test',
294 292 owner=TEST_USER_ADMIN_LOGIN)
295 293 perm = Permission.get_by_key('repository.write')
296 294 RepoGroupModel().grant_user_permission(
297 295 gr, TEST_USER_REGULAR_LOGIN, perm)
298 296
299 297 # add repo permissions
300 298 Session().commit()
301 299 repo_group_id = gr.group_id
302 300 repo_name = 'ingroup_inherited_%s' % backend.alias
303 301 repo_name_full = RepoGroup.url_sep().join([group_name, repo_name])
304 302 description = 'description for newly created repo'
305 303 self.app.post(
306 304 route_path('repo_create'),
307 305 fixture._get_repo_create_params(
308 306 repo_private=False,
309 307 repo_name=repo_name,
310 308 repo_type=backend.alias,
311 309 repo_description=description,
312 310 repo_group=repo_group_id,
313 311 repo_copy_permissions=True,
314 312 csrf_token=csrf_token))
315 313
316 314 # TODO: johbo: Cleanup to pytest fixture
317 315 try:
318 316 self.assert_repository_is_created_correctly(
319 317 repo_name_full, description, backend)
320 318 except Exception:
321 319 RepoGroupModel().delete(group_name)
322 320 Session().commit()
323 321 raise
324 322
325 323 # check if inherited permissions are applied
326 324 new_repo = RepoModel().get_by_repo_name(repo_name_full)
327 325 inherited_perms = UserRepoToPerm.query().filter(
328 326 UserRepoToPerm.repository_id == new_repo.repo_id).all()
329 327 assert len(inherited_perms) == 2
330 328
331 329 assert TEST_USER_REGULAR_LOGIN in [
332 330 x.user.username for x in inherited_perms]
333 331 assert 'repository.write' in [
334 332 x.permission.permission_name for x in inherited_perms]
335 333
336 334 RepoModel().delete(repo_name_full)
337 335 RepoGroupModel().delete(group_name)
338 336 Session().commit()
339 337
340 338 @pytest.mark.xfail_backends(
341 339 "git", "hg", reason="Missing reposerver support")
342 340 def test_create_with_clone_uri(self, autologin_user, backend, reposerver,
343 341 csrf_token):
344 342 source_repo = backend.create_repo(number_of_commits=2)
345 343 source_repo_name = source_repo.repo_name
346 344 reposerver.serve(source_repo.scm_instance())
347 345
348 346 repo_name = backend.new_repo_name()
349 347 response = self.app.post(
350 348 route_path('repo_create'),
351 349 fixture._get_repo_create_params(
352 350 repo_private=False,
353 351 repo_name=repo_name,
354 352 repo_type=backend.alias,
355 353 repo_description='',
356 354 clone_uri=reposerver.url,
357 355 csrf_token=csrf_token),
358 356 status=302)
359 357
360 358 # Should be redirected to the creating page
361 359 response.mustcontain('repo_creating')
362 360
363 361 # Expecting that both repositories have same history
364 362 source_repo = RepoModel().get_by_repo_name(source_repo_name)
365 363 source_vcs = source_repo.scm_instance()
366 364 repo = RepoModel().get_by_repo_name(repo_name)
367 365 repo_vcs = repo.scm_instance()
368 366 assert source_vcs[0].message == repo_vcs[0].message
369 367 assert source_vcs.count() == repo_vcs.count()
370 368 assert source_vcs.commit_ids == repo_vcs.commit_ids
371 369
372 370 @pytest.mark.xfail_backends("svn", reason="Depends on import support")
373 371 def test_create_remote_repo_wrong_clone_uri(self, autologin_user, backend,
374 372 csrf_token):
375 373 repo_name = backend.new_repo_name()
376 374 description = 'description for newly created repo'
377 375 response = self.app.post(
378 376 route_path('repo_create'),
379 377 fixture._get_repo_create_params(
380 378 repo_private=False,
381 379 repo_name=repo_name,
382 380 repo_type=backend.alias,
383 381 repo_description=description,
384 382 clone_uri='http://repo.invalid/repo',
385 383 csrf_token=csrf_token))
386 384 response.mustcontain('invalid clone url')
387 385
388 386 @pytest.mark.xfail_backends("svn", reason="Depends on import support")
389 387 def test_create_remote_repo_wrong_clone_uri_hg_svn(
390 388 self, autologin_user, backend, csrf_token):
391 389 repo_name = backend.new_repo_name()
392 390 description = 'description for newly created repo'
393 391 response = self.app.post(
394 392 route_path('repo_create'),
395 393 fixture._get_repo_create_params(
396 394 repo_private=False,
397 395 repo_name=repo_name,
398 396 repo_type=backend.alias,
399 397 repo_description=description,
400 398 clone_uri='svn+http://svn.invalid/repo',
401 399 csrf_token=csrf_token))
402 400 response.mustcontain('invalid clone url')
403 401
404 402 def test_create_with_git_suffix(
405 403 self, autologin_user, backend, csrf_token):
406 404 repo_name = backend.new_repo_name() + ".git"
407 405 description = 'description for newly created repo'
408 406 response = self.app.post(
409 407 route_path('repo_create'),
410 408 fixture._get_repo_create_params(
411 409 repo_private=False,
412 410 repo_name=repo_name,
413 411 repo_type=backend.alias,
414 412 repo_description=description,
415 413 csrf_token=csrf_token))
416 414 response.mustcontain('Repository name cannot end with .git')
417 415
418 416 def test_default_user_cannot_access_private_repo_in_a_group(
419 417 self, autologin_user, user_util, backend):
420 418
421 419 group = user_util.create_repo_group()
422 420
423 421 repo = backend.create_repo(
424 422 repo_private=True, repo_group=group, repo_copy_permissions=True)
425 423
426 424 permissions = _get_permission_for_user(
427 425 user='default', repo=repo.repo_name)
428 426 assert len(permissions) == 1
429 427 assert permissions[0].permission.permission_name == 'repository.none'
430 428 assert permissions[0].repository.private is True
431 429
432 430 def test_create_on_top_level_without_permissions(self, backend):
433 431 session = login_user_session(
434 432 self.app, TEST_USER_REGULAR_LOGIN, TEST_USER_REGULAR_PASS)
435 433 csrf_token = auth.get_csrf_token(session)
436 434
437 435 # revoke
438 436 user_model = UserModel()
439 437 # disable fork and create on default user
440 438 user_model.revoke_perm(User.DEFAULT_USER, 'hg.create.repository')
441 439 user_model.grant_perm(User.DEFAULT_USER, 'hg.create.none')
442 440 user_model.revoke_perm(User.DEFAULT_USER, 'hg.fork.repository')
443 441 user_model.grant_perm(User.DEFAULT_USER, 'hg.fork.none')
444 442
445 443 # disable on regular user
446 444 user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.repository')
447 445 user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.create.none')
448 446 user_model.revoke_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.repository')
449 447 user_model.grant_perm(TEST_USER_REGULAR_LOGIN, 'hg.fork.none')
450 448 Session().commit()
451 449
452 450 repo_name = backend.new_repo_name()
453 451 description = 'description for newly created repo'
454 452 response = self.app.post(
455 453 route_path('repo_create'),
456 454 fixture._get_repo_create_params(
457 455 repo_private=False,
458 456 repo_name=repo_name,
459 457 repo_type=backend.alias,
460 458 repo_description=description,
461 459 csrf_token=csrf_token))
462 460
463 461 response.mustcontain(
464 462 u"You do not have the permission to store repositories in "
465 463 u"the root location.")
466 464
467 465 @mock.patch.object(RepoModel, '_create_filesystem_repo', error_function)
468 466 def test_create_repo_when_filesystem_op_fails(
469 467 self, autologin_user, backend, csrf_token):
470 468 repo_name = backend.new_repo_name()
471 469 description = 'description for newly created repo'
472 470
473 471 response = self.app.post(
474 472 route_path('repo_create'),
475 473 fixture._get_repo_create_params(
476 474 repo_private=False,
477 475 repo_name=repo_name,
478 476 repo_type=backend.alias,
479 477 repo_description=description,
480 478 csrf_token=csrf_token))
481 479
482 480 assert_session_flash(
483 481 response, 'Error creating repository %s' % repo_name)
484 482 # repo must not be in db
485 483 assert backend.repo is None
486 484 # repo must not be in filesystem !
487 485 assert not repo_on_filesystem(repo_name)
488 486
489 487 def assert_repository_is_created_correctly(
490 488 self, repo_name, description, backend):
491 489 repo_name_utf8 = safe_str(repo_name)
492 490
493 491 # run the check page that triggers the flash message
494 492 response = self.app.get(
495 493 route_path('repo_creating_check', repo_name=safe_str(repo_name)))
496 494 assert response.json == {u'result': True}
497 495
498 496 flash_msg = u'Created repository <a href="/{}">{}</a>'.format(
499 497 urllib.quote(repo_name_utf8), repo_name)
500 498 assert_session_flash(response, flash_msg)
501 499
502 500 # test if the repo was created in the database
503 501 new_repo = RepoModel().get_by_repo_name(repo_name)
504 502
505 503 assert new_repo.repo_name == repo_name
506 504 assert new_repo.description == description
507 505
508 506 # test if the repository is visible in the list ?
509 507 response = self.app.get(
510 508 h.route_path('repo_summary', repo_name=safe_str(repo_name)))
511 509 response.mustcontain(repo_name)
512 510 response.mustcontain(backend.alias)
513 511
514 512 assert repo_on_filesystem(repo_name)
@@ -1,175 +1,169 b''
1 1 ## -*- coding: utf-8 -*-
2 2
3 3 ${h.secure_form(h.route_path('repo_create'), request=request)}
4 4 <div class="form">
5 5 <!-- fields -->
6 6 <div class="fields">
7 7 <div class="field">
8 8 <div class="label">
9 9 <label for="repo_name">${_('Repository name')}:</label>
10 10 </div>
11 11 <div class="input">
12 12 ${h.text('repo_name', class_="medium")}
13 13 <div class="info-block">
14 14 <a id="remote_clone_toggle" href="#">${_('Import Existing Repository ?')}</a>
15 15 </div>
16 16 %if not c.rhodecode_user.is_admin:
17 17 ${h.hidden('user_created',True)}
18 18 %endif
19 19 </div>
20 20 </div>
21 21 <div id="remote_clone" class="field" style="display: none;">
22 22 <div class="label">
23 23 <label for="clone_uri">${_('Clone from')}:</label>
24 24 </div>
25 25 <div class="input">
26 26 ${h.text('clone_uri', class_="medium")}
27 27 <span class="help-block">
28 28 <pre>
29 29 - The repository must be accessible over http:// or https://
30 30 - For Git projects it's recommended appending .git to the end of clone url.
31 31 - Make sure to select proper repository type from the below selector before importing it.
32 32 - If your HTTP[S] repository is not publicly accessible,
33 33 add authentication information to the URL: https://username:password@server.company.com/repo-name.
34 34 - The Git LFS/Mercurial Largefiles objects will not be imported.
35 35 - For very large repositories, it's recommended to manually copy them into the
36 36 RhodeCode <a href="${h.route_path('admin_settings_vcs', _anchor='vcs-storage-options')}">storage location</a> and run <a href="${h.route_path('admin_settings_mapping')}">Remap and Rescan</a>.
37 37 </pre>
38 38 </span>
39 39 </div>
40 40 </div>
41 41 <div class="field">
42 42 <div class="label">
43 43 <label for="repo_group">${_('Repository group')}:</label>
44 44 </div>
45 45 <div class="select">
46 46 ${h.select('repo_group',request.GET.get('parent_group'),c.repo_groups,class_="medium")}
47 47 % if c.personal_repo_group:
48 48 <a class="btn" href="#" id="select_my_group" data-personal-group-id="${c.personal_repo_group.group_id}">
49 49 ${_('Select my personal group (%(repo_group_name)s)') % {'repo_group_name': c.personal_repo_group.group_name}}
50 50 </a>
51 51 % endif
52 52 <span class="help-block">${_('Optionally select a group to put this repository into.')}</span>
53 53 </div>
54 54 </div>
55 55
56 56 <div class="field">
57 57 <div class="label">
58 58 <label for="repo_type">${_('Type')}:</label>
59 59 </div>
60 60 <div class="fields repo-type-radio">
61 61
62 62
63 63 % for backend in c.backends:
64 64 % if loop.index == 0:
65 65 <input id="repo_type_${backend}" name="repo_type" type="radio" value="${backend}" checked="checked"/>
66 66 % else:
67 67 <input id="repo_type_${backend}" name="repo_type" type="radio" value="${backend}" />
68 68 % endif
69 69
70 70 <label for="repo_type_${backend}">
71 71 <i class="icon-${backend}" style="font-size: 16px"></i>
72 72 ${backend.upper()}
73 73 </label>
74 74
75 75 % endfor
76 76
77 77
78 78 <span class="help-block">${_('Set the type of repository to create.')}</span>
79 79 </div>
80 80 </div>
81 81 <div class="field">
82 82 <div class="label">
83 83 <label for="repo_description">${_('Description')}:</label>
84 84 </div>
85 85 <div class="textarea editor">
86 86 ${h.textarea('repo_description',cols=23,rows=5,class_="medium")}
87 87 <% metatags_url = h.literal('''<a href="#metatagsShow" onclick="$('#meta-tags-desc').toggle();return false">meta-tags</a>''') %>
88 88 <span class="help-block">
89 89 % if c.visual.stylify_metatags:
90 90 ${_('Plain text format with {metatags} support.').format(metatags=metatags_url)|n}
91 91 % else:
92 92 ${_('Plain text format.')}
93 93 % endif
94 94 ${_('Add a README file for longer descriptions')}
95 95 </span>
96 96 <span id="meta-tags-desc" style="display: none">
97 97 <%namespace name="dt" file="/data_table/_dt_elements.mako"/>
98 98 ${dt.metatags_help()}
99 99 </span>
100 100 </div>
101 101 </div>
102 102 <div id="copy_perms" class="field">
103 103 <div class="label label-checkbox">
104 104 <label for="repo_copy_permissions">${_('Copy Parent Group Permissions')}:</label>
105 105 </div>
106 106 <div class="checkboxes">
107 107 ${h.checkbox('repo_copy_permissions', value="True", checked="checked")}
108 108 <span class="help-block">${_('Copy permissions from parent repository group.')}</span>
109 109 </div>
110 110 </div>
111 111 <div class="field">
112 112 <div class="label label-checkbox">
113 113 <label for="repo_private">${_('Private Repository')}:</label>
114 114 </div>
115 115 <div class="checkboxes">
116 116 ${h.checkbox('repo_private',value="True")}
117 117 <span class="help-block">${_('Private repositories are only visible to people explicitly added as collaborators.')}</span>
118 118 </div>
119 119 </div>
120 120 <div class="buttons">
121 121 ${h.submit('save',_('Create Repository'),class_="btn")}
122 122 </div>
123 123 </div>
124 124 </div>
125 125 <script>
126 126 $(document).ready(function(){
127 127 var setCopyPermsOption = function(group_val){
128 128 if(group_val != "-1"){
129 129 $('#copy_perms').show()
130 130 }
131 131 else{
132 132 $('#copy_perms').hide();
133 133 }
134 134 };
135 135
136 136 $('#remote_clone_toggle').on('click', function(e){
137 137 $('#remote_clone').show();
138 138 e.preventDefault();
139 139 });
140 140
141 141 if($('#remote_clone input').hasClass('error')){
142 142 $('#remote_clone').show();
143 143 }
144 144 if($('#remote_clone input').val()){
145 145 $('#remote_clone').show();
146 146 }
147 147
148 148 $("#repo_group").select2({
149 149 'containerCssClass': "drop-menu",
150 150 'dropdownCssClass': "drop-menu-dropdown",
151 151 'dropdownAutoWidth': true,
152 152 'width': "resolve"
153 153 });
154 154
155 155 setCopyPermsOption($('#repo_group').val());
156 156 $("#repo_group").on("change", function(e) {
157 157 setCopyPermsOption(e.val)
158 158 });
159 159
160 $("#repo_type").select2({
161 'containerCssClass': "drop-menu",
162 'dropdownCssClass': "drop-menu-dropdown",
163 'minimumResultsForSearch': -1,
164 });
165
166 160 $('#repo_name').focus();
167 161
168 162 $('#select_my_group').on('click', function(e){
169 163 e.preventDefault();
170 164 $("#repo_group").val($(this).data('personalGroupId')).trigger("change");
171 165 })
172 166
173 167 })
174 168 </script>
175 169 ${h.end_form()}
General Comments 0
You need to be logged in to leave comments. Login now