Show More
@@ -0,0 +1,178 b'' | |||
|
1 | # -*- coding: utf-8 -*- | |
|
2 | ||
|
3 | # Copyright (C) 2011-2017 RhodeCode GmbH | |
|
4 | # | |
|
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 | |
|
7 | # (only), as published by the Free Software Foundation. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
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/>. | |
|
16 | # | |
|
17 | # This program is dual-licensed. If you wish to learn more about the | |
|
18 | # RhodeCode Enterprise Edition, including its added features, Support services, | |
|
19 | # and proprietary license terms, please see https://rhodecode.com/licenses/ | |
|
20 | ||
|
21 | import logging | |
|
22 | ||
|
23 | import deform | |
|
24 | from pyramid.httpexceptions import HTTPFound | |
|
25 | from pyramid.view import view_config | |
|
26 | ||
|
27 | from rhodecode.apps._base import RepoAppView | |
|
28 | from rhodecode.forms import RcForm | |
|
29 | from rhodecode.lib import helpers as h | |
|
30 | from rhodecode.lib import audit_logger | |
|
31 | from rhodecode.lib.auth import ( | |
|
32 | LoginRequired, HasRepoPermissionAnyDecorator, | |
|
33 | HasRepoPermissionAllDecorator, CSRFRequired) | |
|
34 | from rhodecode.model.db import RepositoryField, RepoGroup | |
|
35 | from rhodecode.model.meta import Session | |
|
36 | from rhodecode.model.repo import RepoModel | |
|
37 | from rhodecode.model.scm import RepoGroupList, ScmModel | |
|
38 | from rhodecode.model.validation_schema.schemas import repo_schema | |
|
39 | ||
|
40 | log = logging.getLogger(__name__) | |
|
41 | ||
|
42 | ||
|
43 | class RepoSettingsView(RepoAppView): | |
|
44 | ||
|
45 | def load_default_context(self): | |
|
46 | c = self._get_local_tmpl_context() | |
|
47 | ||
|
48 | # TODO(marcink): remove repo_info and use c.rhodecode_db_repo instead | |
|
49 | c.repo_info = self.db_repo | |
|
50 | ||
|
51 | acl_groups = RepoGroupList( | |
|
52 | RepoGroup.query().all(), | |
|
53 | perm_set=['group.write', 'group.admin']) | |
|
54 | c.repo_groups = RepoGroup.groups_choices(groups=acl_groups) | |
|
55 | c.repo_groups_choices = map(lambda k: k[0], c.repo_groups) | |
|
56 | ||
|
57 | # in case someone no longer have a group.write access to a repository | |
|
58 | # pre fill the list with this entry, we don't care if this is the same | |
|
59 | # but it will allow saving repo data properly. | |
|
60 | repo_group = self.db_repo.group | |
|
61 | if repo_group and repo_group.group_id not in c.repo_groups_choices: | |
|
62 | c.repo_groups_choices.append(repo_group.group_id) | |
|
63 | c.repo_groups.append(RepoGroup._generate_choice(repo_group)) | |
|
64 | ||
|
65 | if c.repository_requirements_missing or self.rhodecode_vcs_repo is None: | |
|
66 | # we might be in missing requirement state, so we load things | |
|
67 | # without touching scm_instance() | |
|
68 | c.landing_revs_choices, c.landing_revs = \ | |
|
69 | ScmModel().get_repo_landing_revs() | |
|
70 | else: | |
|
71 | c.landing_revs_choices, c.landing_revs = \ | |
|
72 | ScmModel().get_repo_landing_revs(self.db_repo) | |
|
73 | ||
|
74 | c.personal_repo_group = c.auth_user.personal_repo_group | |
|
75 | c.repo_fields = RepositoryField.query()\ | |
|
76 | .filter(RepositoryField.repository == self.db_repo).all() | |
|
77 | ||
|
78 | self._register_global_c(c) | |
|
79 | return c | |
|
80 | ||
|
81 | def _get_schema(self, c, old_values=None): | |
|
82 | return repo_schema.RepoSettingsSchema().bind( | |
|
83 | repo_type_options=[self.db_repo.repo_type], | |
|
84 | repo_ref_options=c.landing_revs_choices, | |
|
85 | repo_ref_items=c.landing_revs, | |
|
86 | repo_repo_group_options=c.repo_groups_choices, | |
|
87 | repo_repo_group_items=c.repo_groups, | |
|
88 | # user caller | |
|
89 | user=self._rhodecode_user, | |
|
90 | old_values=old_values | |
|
91 | ) | |
|
92 | ||
|
93 | @LoginRequired() | |
|
94 | @HasRepoPermissionAnyDecorator('repository.admin') | |
|
95 | @view_config( | |
|
96 | route_name='edit_repo', request_method='GET', | |
|
97 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
|
98 | def edit_settings(self): | |
|
99 | c = self.load_default_context() | |
|
100 | c.active = 'settings' | |
|
101 | ||
|
102 | defaults = RepoModel()._get_defaults(self.db_repo_name) | |
|
103 | defaults['repo_owner'] = defaults['user'] | |
|
104 | defaults['repo_landing_commit_ref'] = defaults['repo_landing_rev'] | |
|
105 | ||
|
106 | schema = self._get_schema(c) | |
|
107 | c.form = RcForm(schema, appstruct=defaults) | |
|
108 | return self._get_template_context(c) | |
|
109 | ||
|
110 | @LoginRequired() | |
|
111 | @HasRepoPermissionAllDecorator('repository.admin') | |
|
112 | @CSRFRequired() | |
|
113 | @view_config( | |
|
114 | route_name='edit_repo', request_method='POST', | |
|
115 | renderer='rhodecode:templates/admin/repos/repo_edit.mako') | |
|
116 | def edit_settings_update(self): | |
|
117 | _ = self.request.translate | |
|
118 | c = self.load_default_context() | |
|
119 | c.active = 'settings' | |
|
120 | old_repo_name = self.db_repo_name | |
|
121 | ||
|
122 | old_values = self.db_repo.get_api_data() | |
|
123 | schema = self._get_schema(c, old_values=old_values) | |
|
124 | ||
|
125 | c.form = RcForm(schema) | |
|
126 | pstruct = self.request.POST.items() | |
|
127 | pstruct.append(('repo_type', self.db_repo.repo_type)) | |
|
128 | try: | |
|
129 | schema_data = c.form.validate(pstruct) | |
|
130 | except deform.ValidationFailure as err_form: | |
|
131 | return self._get_template_context(c) | |
|
132 | ||
|
133 | # data is now VALID, proceed with updates | |
|
134 | # save validated data back into the updates dict | |
|
135 | validated_updates = dict( | |
|
136 | repo_name=schema_data['repo_group']['repo_name_without_group'], | |
|
137 | repo_group=schema_data['repo_group']['repo_group_id'], | |
|
138 | ||
|
139 | user=schema_data['repo_owner'], | |
|
140 | repo_description=schema_data['repo_description'], | |
|
141 | repo_private=schema_data['repo_private'], | |
|
142 | clone_uri=schema_data['repo_clone_uri'], | |
|
143 | repo_landing_rev=schema_data['repo_landing_commit_ref'], | |
|
144 | repo_enable_statistics=schema_data['repo_enable_statistics'], | |
|
145 | repo_enable_locking=schema_data['repo_enable_locking'], | |
|
146 | repo_enable_downloads=schema_data['repo_enable_downloads'], | |
|
147 | ) | |
|
148 | # detect if CLONE URI changed, if we get OLD means we keep old values | |
|
149 | if schema_data['repo_clone_uri_change'] == 'OLD': | |
|
150 | validated_updates['clone_uri'] = self.db_repo.clone_uri | |
|
151 | ||
|
152 | # use the new full name for redirect | |
|
153 | new_repo_name = schema_data['repo_group']['repo_name_with_group'] | |
|
154 | ||
|
155 | # save extra fields into our validated data | |
|
156 | for key, value in pstruct: | |
|
157 | if key.startswith(RepositoryField.PREFIX): | |
|
158 | validated_updates[key] = value | |
|
159 | ||
|
160 | try: | |
|
161 | RepoModel().update(self.db_repo, **validated_updates) | |
|
162 | ScmModel().mark_for_invalidation(new_repo_name) | |
|
163 | ||
|
164 | audit_logger.store( | |
|
165 | 'repo.edit', action_data={'old_data': old_values}, | |
|
166 | user=self._rhodecode_user, repo=self.db_repo) | |
|
167 | ||
|
168 | Session().commit() | |
|
169 | ||
|
170 | h.flash(_('Repository {} updated successfully').format( | |
|
171 | old_repo_name), category='success') | |
|
172 | except Exception: | |
|
173 | log.exception("Exception during update of repository") | |
|
174 | h.flash(_('Error occurred during update of repository {}').format( | |
|
175 | old_repo_name), category='error') | |
|
176 | ||
|
177 | raise HTTPFound( | |
|
178 | self.request.route_path('edit_repo', repo_name=new_repo_name)) |
@@ -21,6 +21,11 b'' | |||
|
21 | 21 | |
|
22 | 22 | def includeme(config): |
|
23 | 23 | |
|
24 | # Settings | |
|
25 | config.add_route( | |
|
26 | name='edit_repo', | |
|
27 | pattern='/{repo_name:.*?[^/]}/settings', repo_route=True) | |
|
28 | ||
|
24 | 29 | config.add_route( |
|
25 | 30 | name='repo_maintenance', |
|
26 | 31 | pattern='/{repo_name:.*?[^/]}/maintenance', repo_route=True) |
@@ -29,7 +34,6 b' def includeme(config):' | |||
|
29 | 34 | name='repo_maintenance_execute', |
|
30 | 35 | pattern='/{repo_name:.*?[^/]}/maintenance/execute', repo_route=True) |
|
31 | 36 | |
|
32 | ||
|
33 | 37 | # Strip |
|
34 | 38 | config.add_route( |
|
35 | 39 | name='strip', |
@@ -200,10 +200,6 b' def make_map(config):' | |||
|
200 | 200 | action='index', conditions={'method': ['GET']}) |
|
201 | 201 | m.connect('new_repo', '/create_repository', jsroute=True, |
|
202 | 202 | action='create_repository', conditions={'method': ['GET']}) |
|
203 | m.connect('/repos/{repo_name}', | |
|
204 | action='update', conditions={'method': ['PUT'], | |
|
205 | 'function': check_repo}, | |
|
206 | requirements=URL_NAME_REQUIREMENTS) | |
|
207 | 203 | m.connect('delete_repo', '/repos/{repo_name}', |
|
208 | 204 | action='delete', conditions={'method': ['DELETE']}, |
|
209 | 205 | requirements=URL_NAME_REQUIREMENTS) |
@@ -665,11 +661,6 b' def make_map(config):' | |||
|
665 | 661 | requirements=URL_NAME_REQUIREMENTS) |
|
666 | 662 | |
|
667 | 663 | # repo edit options |
|
668 | rmap.connect('edit_repo', '/{repo_name}/settings', jsroute=True, | |
|
669 | controller='admin/repos', action='edit', | |
|
670 | conditions={'method': ['GET'], 'function': check_repo}, | |
|
671 | requirements=URL_NAME_REQUIREMENTS) | |
|
672 | ||
|
673 | 664 | rmap.connect('edit_repo_perms', '/{repo_name}/settings/permissions', |
|
674 | 665 | jsroute=True, |
|
675 | 666 | controller='admin/repos', action='edit_permissions', |
@@ -290,65 +290,6 b' class ReposController(BaseRepoController' | |||
|
290 | 290 | |
|
291 | 291 | @HasRepoPermissionAllDecorator('repository.admin') |
|
292 | 292 | @auth.CSRFRequired() |
|
293 | def update(self, repo_name): | |
|
294 | """ | |
|
295 | PUT /repos/repo_name: Update an existing item""" | |
|
296 | # Forms posted to this method should contain a hidden field: | |
|
297 | # <input type="hidden" name="_method" value="PUT" /> | |
|
298 | # Or using helpers: | |
|
299 | # h.form(url('repo', repo_name=ID), | |
|
300 | # method='put') | |
|
301 | # url('repo', repo_name=ID) | |
|
302 | ||
|
303 | self.__load_data(repo_name) | |
|
304 | c.active = 'settings' | |
|
305 | c.repo_fields = RepositoryField.query()\ | |
|
306 | .filter(RepositoryField.repository == c.repo_info).all() | |
|
307 | ||
|
308 | repo_model = RepoModel() | |
|
309 | changed_name = repo_name | |
|
310 | ||
|
311 | c.personal_repo_group = c.rhodecode_user.personal_repo_group | |
|
312 | # override the choices with extracted revisions ! | |
|
313 | repo = Repository.get_by_repo_name(repo_name) | |
|
314 | old_data = { | |
|
315 | 'repo_name': repo_name, | |
|
316 | 'repo_group': repo.group.get_dict() if repo.group else {}, | |
|
317 | 'repo_type': repo.repo_type, | |
|
318 | } | |
|
319 | _form = RepoForm( | |
|
320 | edit=True, old_data=old_data, repo_groups=c.repo_groups_choices, | |
|
321 | landing_revs=c.landing_revs_choices, allow_disabled=True)() | |
|
322 | ||
|
323 | try: | |
|
324 | form_result = _form.to_python(dict(request.POST)) | |
|
325 | repo = repo_model.update(repo_name, **form_result) | |
|
326 | ScmModel().mark_for_invalidation(repo_name) | |
|
327 | h.flash(_('Repository %s updated successfully') % repo_name, | |
|
328 | category='success') | |
|
329 | changed_name = repo.repo_name | |
|
330 | action_logger(c.rhodecode_user, 'admin_updated_repo', | |
|
331 | changed_name, self.ip_addr, self.sa) | |
|
332 | Session().commit() | |
|
333 | except formencode.Invalid as errors: | |
|
334 | defaults = self.__load_data(repo_name) | |
|
335 | defaults.update(errors.value) | |
|
336 | return htmlfill.render( | |
|
337 | render('admin/repos/repo_edit.mako'), | |
|
338 | defaults=defaults, | |
|
339 | errors=errors.error_dict or {}, | |
|
340 | prefix_error=False, | |
|
341 | encoding="UTF-8", | |
|
342 | force_defaults=False) | |
|
343 | ||
|
344 | except Exception: | |
|
345 | log.exception("Exception during update of repository") | |
|
346 | h.flash(_('Error occurred during update of repository %s') \ | |
|
347 | % repo_name, category='error') | |
|
348 | return redirect(url('edit_repo', repo_name=changed_name)) | |
|
349 | ||
|
350 | @HasRepoPermissionAllDecorator('repository.admin') | |
|
351 | @auth.CSRFRequired() | |
|
352 | 293 | def delete(self, repo_name): |
|
353 | 294 | """ |
|
354 | 295 | DELETE /repos/repo_name: Delete an existing item""" |
@@ -398,27 +339,8 b' class ReposController(BaseRepoController' | |||
|
398 | 339 | # url('repo', repo_name=ID) |
|
399 | 340 | |
|
400 | 341 | @HasRepoPermissionAllDecorator('repository.admin') |
|
401 | def edit(self, repo_name): | |
|
402 | """GET /repo_name/settings: Form to edit an existing item""" | |
|
403 | # url('edit_repo', repo_name=ID) | |
|
404 | defaults = self.__load_data(repo_name) | |
|
405 | if 'clone_uri' in defaults: | |
|
406 | del defaults['clone_uri'] | |
|
407 | ||
|
408 | c.repo_fields = RepositoryField.query()\ | |
|
409 | .filter(RepositoryField.repository == c.repo_info).all() | |
|
410 | c.personal_repo_group = c.rhodecode_user.personal_repo_group | |
|
411 | c.active = 'settings' | |
|
412 | return htmlfill.render( | |
|
413 | render('admin/repos/repo_edit.mako'), | |
|
414 | defaults=defaults, | |
|
415 | encoding="UTF-8", | |
|
416 | force_defaults=False) | |
|
417 | ||
|
418 | @HasRepoPermissionAllDecorator('repository.admin') | |
|
419 | 342 | def edit_permissions(self, repo_name): |
|
420 | 343 | """GET /repo_name/settings: Form to edit an existing item""" |
|
421 | # url('edit_repo', repo_name=ID) | |
|
422 | 344 | c.repo_info = self._load_repo(repo_name) |
|
423 | 345 | c.active = 'permissions' |
|
424 | 346 | defaults = RepoModel()._get_defaults(repo_name) |
@@ -446,7 +368,6 b' class ReposController(BaseRepoController' | |||
|
446 | 368 | @HasRepoPermissionAllDecorator('repository.admin') |
|
447 | 369 | def edit_fields(self, repo_name): |
|
448 | 370 | """GET /repo_name/settings: Form to edit an existing item""" |
|
449 | # url('edit_repo', repo_name=ID) | |
|
450 | 371 | c.repo_info = self._load_repo(repo_name) |
|
451 | 372 | c.repo_fields = RepositoryField.query()\ |
|
452 | 373 | .filter(RepositoryField.repository == c.repo_info).all() |
@@ -493,7 +414,6 b' class ReposController(BaseRepoController' | |||
|
493 | 414 | @HasRepoPermissionAllDecorator('repository.admin') |
|
494 | 415 | def edit_advanced(self, repo_name): |
|
495 | 416 | """GET /repo_name/settings: Form to edit an existing item""" |
|
496 | # url('edit_repo', repo_name=ID) | |
|
497 | 417 | c.repo_info = self._load_repo(repo_name) |
|
498 | 418 | c.default_user_id = User.get_default_user().user_id |
|
499 | 419 | c.in_public_journal = UserFollowing.query()\ |
@@ -638,7 +558,6 b' class ReposController(BaseRepoController' | |||
|
638 | 558 | @HasRepoPermissionAllDecorator('repository.admin') |
|
639 | 559 | def edit_caches_form(self, repo_name): |
|
640 | 560 | """GET /repo_name/settings: Form to edit an existing item""" |
|
641 | # url('edit_repo', repo_name=ID) | |
|
642 | 561 | c.repo_info = self._load_repo(repo_name) |
|
643 | 562 | c.active = 'caches' |
|
644 | 563 | |
@@ -660,7 +579,6 b' class ReposController(BaseRepoController' | |||
|
660 | 579 | @HasRepoPermissionAllDecorator('repository.admin') |
|
661 | 580 | def edit_remote_form(self, repo_name): |
|
662 | 581 | """GET /repo_name/settings: Form to edit an existing item""" |
|
663 | # url('edit_repo', repo_name=ID) | |
|
664 | 582 | c.repo_info = self._load_repo(repo_name) |
|
665 | 583 | c.active = 'remote' |
|
666 | 584 | |
@@ -682,7 +600,6 b' class ReposController(BaseRepoController' | |||
|
682 | 600 | @HasRepoPermissionAllDecorator('repository.admin') |
|
683 | 601 | def edit_statistics_form(self, repo_name): |
|
684 | 602 | """GET /repo_name/settings: Form to edit an existing item""" |
|
685 | # url('edit_repo', repo_name=ID) | |
|
686 | 603 | c.repo_info = self._load_repo(repo_name) |
|
687 | 604 | repo = c.repo_info.scm_instance() |
|
688 | 605 |
@@ -2184,7 +2184,7 b' class RepoGroup(Base, BaseModel):' | |||
|
2184 | 2184 | |
|
2185 | 2185 | repo_groups = [] |
|
2186 | 2186 | if show_empty_group: |
|
2187 |
repo_groups = [( |
|
|
2187 | repo_groups = [(-1, u'-- %s --' % _('No parent'))] | |
|
2188 | 2188 | |
|
2189 | 2189 | repo_groups.extend([cls._generate_choice(x) for x in groups]) |
|
2190 | 2190 |
@@ -333,12 +333,6 b' class RepoModel(BaseModel):' | |||
|
333 | 333 | val = kwargs[k] |
|
334 | 334 | if strip: |
|
335 | 335 | k = remove_prefix(k, 'repo_') |
|
336 | if k == 'clone_uri': | |
|
337 | from rhodecode.model.validators import Missing | |
|
338 | _change = kwargs.get('clone_uri_change') | |
|
339 | if _change in [Missing, 'OLD']: | |
|
340 | # we don't change the value, so use original one | |
|
341 | val = cur_repo.clone_uri | |
|
342 | 336 | |
|
343 | 337 | setattr(cur_repo, k, val) |
|
344 | 338 |
@@ -24,7 +24,6 b' function registerRCRoutes() {' | |||
|
24 | 24 | pyroutes.register('repo_refs_changelog_data', '/%(repo_name)s/refs-data-changelog', ['repo_name']); |
|
25 | 25 | pyroutes.register('repo_default_reviewers_data', '/%(repo_name)s/default-reviewers', ['repo_name']); |
|
26 | 26 | pyroutes.register('changeset_home', '/%(repo_name)s/changeset/%(revision)s', ['repo_name', 'revision']); |
|
27 | pyroutes.register('edit_repo', '/%(repo_name)s/settings', ['repo_name']); | |
|
28 | 27 | pyroutes.register('edit_repo_perms', '/%(repo_name)s/settings/permissions', ['repo_name']); |
|
29 | 28 | pyroutes.register('changeset_comment', '/%(repo_name)s/changeset/%(revision)s/comment', ['repo_name', 'revision']); |
|
30 | 29 | pyroutes.register('changeset_comment_preview', '/%(repo_name)s/changeset/comment/preview', ['repo_name']); |
@@ -98,6 +97,7 b' function registerRCRoutes() {' | |||
|
98 | 97 | pyroutes.register('user_group_autocomplete_data', '/_user_groups', []); |
|
99 | 98 | pyroutes.register('repo_list_data', '/_repos', []); |
|
100 | 99 | pyroutes.register('goto_switcher_data', '/_goto_data', []); |
|
100 | pyroutes.register('edit_repo', '/%(repo_name)s/settings', ['repo_name']); | |
|
101 | 101 | pyroutes.register('repo_maintenance', '/%(repo_name)s/maintenance', ['repo_name']); |
|
102 | 102 | pyroutes.register('repo_maintenance_execute', '/%(repo_name)s/maintenance/execute', ['repo_name']); |
|
103 | 103 | pyroutes.register('strip', '/%(repo_name)s/strip', ['repo_name']); |
@@ -3,7 +3,7 b'' | |||
|
3 | 3 | |
|
4 | 4 | <%def name="breadcrumbs_links()"> |
|
5 | 5 | %if c.repo: |
|
6 |
${h.link_to('Settings',h. |
|
|
6 | ${h.link_to('Settings',h.route_path('edit_repo', repo_name=c.repo.repo_name))} | |
|
7 | 7 | » |
|
8 | 8 | ${h.link_to(_('Integrations'),request.route_url(route_name='repo_integrations_home', repo_name=c.repo.repo_name))} |
|
9 | 9 | » |
@@ -3,7 +3,7 b'' | |||
|
3 | 3 | |
|
4 | 4 | <%def name="breadcrumbs_links()"> |
|
5 | 5 | %if c.repo: |
|
6 |
${h.link_to('Settings',h. |
|
|
6 | ${h.link_to('Settings',h.route_path('edit_repo', repo_name=c.repo.repo_name))} | |
|
7 | 7 | %elif c.repo_group: |
|
8 | 8 | ${h.link_to(_('Admin'),h.url('admin_home'))} |
|
9 | 9 | » |
@@ -4,7 +4,7 b'' | |||
|
4 | 4 | |
|
5 | 5 | <%def name="breadcrumbs_links()"> |
|
6 | 6 | %if c.repo: |
|
7 |
${h.link_to('Settings',h. |
|
|
7 | ${h.link_to('Settings',h.route_path('edit_repo', repo_name=c.repo.repo_name))} | |
|
8 | 8 | » |
|
9 | 9 | ${h.link_to(_('Integrations'),request.route_url(route_name='repo_integrations_home', repo_name=c.repo.repo_name))} |
|
10 | 10 | %elif c.repo_group: |
@@ -40,7 +40,7 b'' | |||
|
40 | 40 | <div class="sidebar"> |
|
41 | 41 | <ul class="nav nav-pills nav-stacked"> |
|
42 | 42 | <li class="${'active' if c.active=='settings' else ''}"> |
|
43 |
<a href="${h. |
|
|
43 | <a href="${h.route_path('edit_repo', repo_name=c.repo_name)}">${_('Settings')}</a> | |
|
44 | 44 | </li> |
|
45 | 45 | <li class="${'active' if c.active=='permissions' else ''}"> |
|
46 | 46 | <a href="${h.url('edit_repo_perms', repo_name=c.repo_name)}">${_('Permissions')}</a> |
@@ -3,92 +3,110 b'' | |||
|
3 | 3 | |
|
4 | 4 | <div class="panel panel-default"> |
|
5 | 5 | <div class="panel-heading"> |
|
6 |
<h3 class="panel-title">${_('Settings for Repository: %s') % c.r |
|
|
6 | <h3 class="panel-title">${_('Settings for Repository: %s') % c.rhodecode_db_repo.repo_name}</h3> | |
|
7 | 7 | </div> |
|
8 | 8 | <div class="panel-body"> |
|
9 |
${h.secure_form( |
|
|
9 | ${h.secure_form(h.route_path('edit_repo', repo_name=c.rhodecode_db_repo.repo_name), method='POST')} | |
|
10 | 10 | <div class="form"> |
|
11 | 11 | <!-- fields --> |
|
12 | 12 | <div class="fields"> |
|
13 | ||
|
13 | 14 | <div class="field"> |
|
14 | 15 | <div class="label"> |
|
15 | 16 | <label for="repo_name">${_('Name')}:</label> |
|
16 | 17 | </div> |
|
17 | 18 | <div class="input"> |
|
18 |
${ |
|
|
19 | <p class="help-block">${_('Non-changeable id')}: `_${c.repo_info.repo_id}` <span><a id="show_more_clone_id" href="#">${_('what is that ?')}</a></span></p> | |
|
19 | ${c.form['repo_name'].render(css_class='medium', oid='repo_name')|n} | |
|
20 | ${c.form.render_error(request, c.form['repo_name'])|n} | |
|
21 | ||
|
22 | <p class="help-block">${_('Non-changeable id')}: `_${c.rhodecode_db_repo.repo_id}` <span><a href="#" onclick="$('#clone_id').toggle();return false">${_('what is that ?')}</a></span></p> | |
|
20 | 23 | <p id="clone_id" style="display:none;"> |
|
21 |
${_('URL by id')}: `${c.r |
|
|
24 | ${_('URL by id')}: `${c.rhodecode_db_repo.clone_url(with_id=True)}` <br/> | |
|
22 | 25 | ${_('''In case this repository is renamed or moved into another group the repository url changes. |
|
23 | 26 | Using above url guarantees that this repository will always be accessible under such url. |
|
24 | 27 | Useful for CI systems, or any other cases that you need to hardcode the url into 3rd party service.''')}</p> |
|
25 | 28 | </div> |
|
26 | 29 | </div> |
|
27 | % if c.repo_info.repo_type != 'svn': | |
|
30 | ||
|
31 | <div class="field"> | |
|
32 | <div class="label"> | |
|
33 | <label for="repo_group">${_('Repository group')}:</label> | |
|
34 | </div> | |
|
35 | <div class="select"> | |
|
36 | ${c.form['repo_group'].render(css_class='medium', oid='repo_group')|n} | |
|
37 | ${c.form.render_error(request, c.form['repo_group'])|n} | |
|
38 | ||
|
39 | % if c.personal_repo_group: | |
|
40 | <a class="btn" href="#" data-personal-group-name="${c.personal_repo_group.group_name}" data-personal-group-id="${c.personal_repo_group.group_id}" onclick="selectMyGroup(this); return false"> | |
|
41 | ${_('Select my personal group (`%(repo_group_name)s`)') % {'repo_group_name': c.personal_repo_group.group_name}} | |
|
42 | </a> | |
|
43 | % endif | |
|
44 | <p class="help-block">${_('Optional select a group to put this repository into.')}</p> | |
|
45 | </div> | |
|
46 | </div> | |
|
47 | ||
|
48 | % if c.rhodecode_db_repo.repo_type != 'svn': | |
|
28 | 49 | <div class="field"> |
|
29 | 50 | <div class="label"> |
|
30 | 51 | <label for="clone_uri">${_('Remote uri')}:</label> |
|
31 | 52 | </div> |
|
32 | 53 | <div class="input"> |
|
33 |
%if c.r |
|
|
54 | %if c.rhodecode_db_repo.clone_uri: | |
|
55 | ## display | |
|
34 | 56 | <div id="clone_uri_hidden" class='text-as-placeholder'> |
|
35 |
<span id="clone_uri_hidden_value">${c.r |
|
|
57 | <span id="clone_uri_hidden_value">${c.rhodecode_db_repo.clone_uri_hidden}</span> | |
|
36 | 58 | <span class="link" id="edit_clone_uri"><i class="icon-edit"></i>${_('edit')}</span> |
|
37 | 59 | </div> |
|
60 | ## alter field | |
|
38 | 61 | <div id="alter_clone_uri" style="display: none"> |
|
39 |
${ |
|
|
40 | ${h.hidden('clone_uri_change', 'OLD')} | |
|
62 | ${c.form['repo_clone_uri'].render(css_class='medium', oid='clone_uri', placeholder=_('enter new value, or leave empty to remove'))|n} | |
|
63 | ${c.form.render_error(request, c.form['repo_clone_uri'])|n} | |
|
64 | ${h.hidden('repo_clone_uri_change', 'OLD')} | |
|
65 | ||
|
41 | 66 | <span class="link" id="cancel_edit_clone_uri">${_('cancel')}</span> |
|
42 | 67 | </div> |
|
43 | 68 | %else: |
|
44 | 69 | ## not set yet, display form to set it |
|
45 | ${h.text('clone_uri',class_="medium")} | |
|
46 | ${h.hidden('clone_uri_change', 'NEW')} | |
|
70 | ${c.form['repo_clone_uri'].render(css_class='medium', oid='clone_uri')|n} | |
|
71 | ${c.form.render_error(request, c.form['repo_clone_uri'])|n} | |
|
72 | ${h.hidden('repo_clone_uri_change', 'NEW')} | |
|
47 | 73 | %endif |
|
48 |
<p id="alter_clone_uri_help_block" class="help-block"> |
|
|
74 | <p id="alter_clone_uri_help_block" class="help-block"> | |
|
75 | <% pull_link = h.literal(h.link_to('remote sync', h.url('edit_repo_remote', repo_name=c.repo_name))) %> | |
|
76 | ${_('http[s] url where from repository was imported, this field can used for doing {pull_link}.').format(pull_link=pull_link)|n} <br/> | |
|
77 | ${_('This field is stored encrypted inside Database, a format of http://user:password@server.com/repo_name can be used and will be hidden from display.')} | |
|
78 | </p> | |
|
49 | 79 | </div> |
|
50 | 80 | </div> |
|
51 |
|
|
|
52 |
|
|
|
53 |
|
|
|
81 | % else: | |
|
82 | ${h.hidden('repo_clone_uri', '')} | |
|
83 | % endif | |
|
84 | ||
|
54 | 85 | <div class="field"> |
|
55 | 86 | <div class="label"> |
|
56 |
<label for="repo_ |
|
|
87 | <label for="repo_landing_commit_ref">${_('Landing commit')}:</label> | |
|
57 | 88 | </div> |
|
58 | 89 | <div class="select"> |
|
59 | ${h.select('repo_group','',c.repo_groups,class_="medium")} | |
|
60 | % if c.personal_repo_group: | |
|
61 | <a class="btn" href="#" id="select_my_group" data-personal-group-id="${c.personal_repo_group.group_id}"> | |
|
62 | ${_('Select my personal group (%(repo_group_name)s)') % {'repo_group_name': c.personal_repo_group.group_name}} | |
|
63 | </a> | |
|
64 | % endif | |
|
65 | <p class="help-block">${_('Optional select a group to put this repository into.')}</p> | |
|
66 | </div> | |
|
67 | </div> | |
|
68 | <div class="field"> | |
|
69 | <div class="label"> | |
|
70 | <label for="repo_landing_rev">${_('Landing commit')}:</label> | |
|
71 | </div> | |
|
72 | <div class="select"> | |
|
73 | ${h.select('repo_landing_rev','',c.landing_revs,class_="medium")} | |
|
74 | <p class="help-block">${_('Default commit for files page, downloads, whoosh and readme')}</p> | |
|
90 | ${c.form['repo_landing_commit_ref'].render(css_class='medium', oid='repo_landing_commit_ref')|n} | |
|
91 | ${c.form.render_error(request, c.form['repo_landing_commit_ref'])|n} | |
|
92 | <p class="help-block">${_('Default commit for files page, downloads, full text search index and readme')}</p> | |
|
75 | 93 | </div> |
|
76 | 94 | </div> |
|
77 | 95 | |
|
78 | 96 | <div class="field badged-field"> |
|
79 | 97 | <div class="label"> |
|
80 |
<label for=" |
|
|
98 | <label for="repo_owner">${_('Owner')}:</label> | |
|
81 | 99 | </div> |
|
82 | 100 | <div class="input"> |
|
83 | 101 | <div class="badge-input-container"> |
|
84 | 102 | <div class="user-badge"> |
|
85 |
${base.gravatar_with_user(c.r |
|
|
103 | ${base.gravatar_with_user(c.rhodecode_db_repo.user.email, show_disabled=not c.rhodecode_db_repo.user.active)} | |
|
86 | 104 | </div> |
|
87 | 105 | <div class="badge-input-wrap"> |
|
88 |
${ |
|
|
106 | ${c.form['repo_owner'].render(css_class='medium', oid='repo_owner')|n} | |
|
89 | 107 | </div> |
|
90 | 108 | </div> |
|
91 | <form:error name="user"/> | |
|
109 | ${c.form.render_error(request, c.form['repo_owner'])|n} | |
|
92 | 110 | <p class="help-block">${_('Change owner of this repository.')}</p> |
|
93 | 111 | </div> |
|
94 | 112 | </div> |
@@ -98,44 +116,49 b'' | |||
|
98 | 116 | <label for="repo_description">${_('Description')}:</label> |
|
99 | 117 | </div> |
|
100 | 118 | <div class="textarea text-area editor"> |
|
101 | ${h.textarea('repo_description', )} | |
|
119 | ${c.form['repo_description'].render(css_class='medium', oid='repo_description')|n} | |
|
120 | ${c.form.render_error(request, c.form['repo_description'])|n} | |
|
102 | 121 | <p class="help-block">${_('Keep it short and to the point. Use a README file for longer descriptions.')}</p> |
|
103 | 122 | </div> |
|
104 | 123 | </div> |
|
105 | 124 | |
|
106 | 125 | <div class="field"> |
|
107 | 126 | <div class="label label-checkbox"> |
|
108 | <label for="repo_private">${_('Private repository')}:</label> | |
|
127 | <label for="${c.form['repo_private'].oid}">${_('Private repository')}:</label> | |
|
109 | 128 | </div> |
|
110 | 129 | <div class="checkboxes"> |
|
111 |
${ |
|
|
130 | ${c.form['repo_private'].render(css_class='medium')|n} | |
|
131 | ${c.form.render_error(request, c.form['repo_private'])|n} | |
|
112 | 132 | <span class="help-block">${_('Private repositories are only visible to people explicitly added as collaborators.')}</span> |
|
113 | 133 | </div> |
|
114 | 134 | </div> |
|
115 | 135 | <div class="field"> |
|
116 | 136 | <div class="label label-checkbox"> |
|
117 | <label for="repo_enable_statistics">${_('Enable statistics')}:</label> | |
|
137 | <label for="${c.form['repo_enable_statistics'].oid}">${_('Enable statistics')}:</label> | |
|
118 | 138 | </div> |
|
119 | 139 | <div class="checkboxes"> |
|
120 |
${ |
|
|
140 | ${c.form['repo_enable_statistics'].render(css_class='medium')|n} | |
|
141 | ${c.form.render_error(request, c.form['repo_enable_statistics'])|n} | |
|
121 | 142 | <span class="help-block">${_('Enable statistics window on summary page.')}</span> |
|
122 | 143 | </div> |
|
123 | 144 | </div> |
|
124 | 145 | <div class="field"> |
|
125 | 146 | <div class="label label-checkbox"> |
|
126 | <label for="repo_enable_downloads">${_('Enable downloads')}:</label> | |
|
147 | <label for="${c.form['repo_enable_downloads'].oid}">${_('Enable downloads')}:</label> | |
|
127 | 148 | </div> |
|
128 | 149 | <div class="checkboxes"> |
|
129 |
${ |
|
|
150 | ${c.form['repo_enable_downloads'].render(css_class='medium')|n} | |
|
151 | ${c.form.render_error(request, c.form['repo_enable_downloads'])|n} | |
|
130 | 152 | <span class="help-block">${_('Enable download menu on summary page.')}</span> |
|
131 | 153 | </div> |
|
132 | 154 | </div> |
|
133 | 155 | <div class="field"> |
|
134 | 156 | <div class="label label-checkbox"> |
|
135 | <label for="repo_enable_locking">${_('Enable automatic locking')}:</label> | |
|
157 | <label for="${c.form['repo_enable_locking'].oid}">${_('Enable automatic locking')}:</label> | |
|
136 | 158 | </div> |
|
137 | 159 | <div class="checkboxes"> |
|
138 |
${ |
|
|
160 | ${c.form['repo_enable_locking'].render(css_class='medium')|n} | |
|
161 | ${c.form.render_error(request, c.form['repo_enable_locking'])|n} | |
|
139 | 162 | <span class="help-block">${_('Enable automatic locking on repository. Pulling from this repository creates a lock that can be released by pushing back by the same user')}</span> |
|
140 | 163 | </div> |
|
141 | 164 | </div> |
@@ -168,12 +191,6 b'' | |||
|
168 | 191 | |
|
169 | 192 | <script> |
|
170 | 193 | $(document).ready(function(){ |
|
171 | var select2Options = { | |
|
172 | 'containerCssClass': "drop-menu", | |
|
173 | 'dropdownCssClass': "drop-menu-dropdown", | |
|
174 | 'dropdownAutoWidth': true | |
|
175 | }; | |
|
176 | ||
|
177 | 194 | var cloneUrl = function() { |
|
178 | 195 | var alterButton = $('#alter_clone_uri'); |
|
179 | 196 | var editButton = $('#edit_clone_uri'); |
@@ -182,7 +199,7 b'' | |||
|
182 | 199 | var hiddenUrlValue = $('#clone_uri_hidden_value'); |
|
183 | 200 | var input = $('#clone_uri'); |
|
184 | 201 | var helpBlock = $('#alter_clone_uri_help_block'); |
|
185 | var changedFlag = $('#clone_uri_change'); | |
|
202 | var changedFlag = $('#repo_clone_uri_change'); | |
|
186 | 203 | var originalText = helpBlock.html(); |
|
187 | 204 | var obfuscatedUrl = hiddenUrlValue.html(); |
|
188 | 205 | |
@@ -223,18 +240,10 b'' | |||
|
223 | 240 | initEvents(); |
|
224 | 241 | }(); |
|
225 | 242 | |
|
226 | $('#show_more_clone_id').on('click', function(e){ | |
|
227 | $('#clone_id').show(); | |
|
228 | e.preventDefault(); | |
|
229 | }); | |
|
243 | selectMyGroup = function(element) { | |
|
244 | $("#repo_group").val($(element).data('personalGroupId')).trigger("change"); | |
|
245 | }; | |
|
230 | 246 | |
|
231 | $('#repo_landing_rev').select2(select2Options); | |
|
232 | $('#repo_group').select2(select2Options); | |
|
233 | ||
|
234 | UsersAutoComplete('user', '${c.rhodecode_user.user_id}'); | |
|
235 | $('#select_my_group').on('click', function(e){ | |
|
236 | e.preventDefault(); | |
|
237 | $("#repo_group").val($(this).data('personalGroupId')).trigger("change"); | |
|
238 | }); | |
|
247 | UsersAutoComplete('repo_owner', '${c.rhodecode_user.user_id}'); | |
|
239 | 248 | }); |
|
240 | 249 | </script> |
@@ -246,7 +246,7 b'' | |||
|
246 | 246 | <a class="menulink" href="#" class="dropdown"><div class="menulabel">${_('Options')} <div class="show_more"></div></div></a> |
|
247 | 247 | <ul class="submenu"> |
|
248 | 248 | %if h.HasRepoPermissionAll('repository.admin')(c.repo_name): |
|
249 |
<li><a href="${h. |
|
|
249 | <li><a href="${h.route_path('edit_repo',repo_name=c.repo_name)}">${_('Settings')}</a></li> | |
|
250 | 250 | %endif |
|
251 | 251 | %if c.rhodecode_db_repo.fork: |
|
252 | 252 | <li><a href="${h.url('compare_url',repo_name=c.rhodecode_db_repo.fork.repo_name,source_ref_type=c.rhodecode_db_repo.landing_rev[0],source_ref=c.rhodecode_db_repo.landing_rev[1], target_repo=c.repo_name,target_ref_type='branch' if request.GET.get('branch') else c.rhodecode_db_repo.landing_rev[0],target_ref=request.GET.get('branch') or c.rhodecode_db_repo.landing_rev[1], merge=1)}"> |
@@ -42,7 +42,7 b'' | |||
|
42 | 42 | %> |
|
43 | 43 | <div class="${'repo_state_pending' if rstate == 'repo_state_pending' else ''} truncate"> |
|
44 | 44 | ##NAME |
|
45 |
<a href="${h. |
|
|
45 | <a href="${h.route_path('edit_repo',repo_name=name) if admin else h.url('summary_home',repo_name=name)}"> | |
|
46 | 46 | |
|
47 | 47 | ##TYPE OF REPO |
|
48 | 48 | %if h.is_hg(rtype): |
@@ -115,7 +115,7 b'' | |||
|
115 | 115 | <%def name="repo_actions(repo_name, super_user=True)"> |
|
116 | 116 | <div> |
|
117 | 117 | <div class="grid_edit"> |
|
118 |
<a href="${h. |
|
|
118 | <a href="${h.route_path('edit_repo',repo_name=repo_name)}" title="${_('Edit')}"> | |
|
119 | 119 | <i class="icon-pencil"></i>Edit</a> |
|
120 | 120 | </div> |
|
121 | 121 | <div class="grid_delete"> |
@@ -145,7 +145,7 b'' | |||
|
145 | 145 | ${_('Statistics are disabled for this repository')} |
|
146 | 146 | </span> |
|
147 | 147 | % if h.HasPermissionAll('hg.admin')('enable stats on from summary'): |
|
148 |
, ${h.link_to(_('enable statistics'),h. |
|
|
148 | , ${h.link_to(_('enable statistics'),h.route_path('edit_repo',repo_name=c.repo_name, anchor='repo_enable_statistics'))} | |
|
149 | 149 | % endif |
|
150 | 150 | % endif |
|
151 | 151 | </div> |
@@ -169,7 +169,7 b'' | |||
|
169 | 169 | ${_('Downloads are disabled for this repository')} |
|
170 | 170 | </span> |
|
171 | 171 | % if h.HasPermissionAll('hg.admin')('enable downloads on from summary'): |
|
172 |
, ${h.link_to(_('enable downloads'),h. |
|
|
172 | , ${h.link_to(_('enable downloads'),h.route_path('edit_repo',repo_name=c.repo_name, anchor='repo_enable_downloads'))} | |
|
173 | 173 | % endif |
|
174 | 174 | % else: |
|
175 | 175 | <span class="enabled"> |
General Comments 0
You need to be logged in to leave comments.
Login now