##// END OF EJS Templates
create: fixed case for repo groups that didn't pre-fill the repo group from GET param....
marcink -
r4424:cbe581e5 default
parent child Browse files
Show More
@@ -69,6 +69,7 b' class AdminRepoGroupsView(BaseAppView, D'
69 c.repo_groups = RepoGroup.groups_choices(
69 c.repo_groups = RepoGroup.groups_choices(
70 groups=groups_with_admin_rights,
70 groups=groups_with_admin_rights,
71 show_empty_group=allow_empty_group)
71 show_empty_group=allow_empty_group)
72 c.personal_repo_group = self._rhodecode_user.personal_repo_group
72
73
73 def _can_create_repo_group(self, parent_group_id=None):
74 def _can_create_repo_group(self, parent_group_id=None):
74 is_admin = HasPermissionAny('hg.admin')('group create controller')
75 is_admin = HasPermissionAny('hg.admin')('group create controller')
@@ -261,15 +262,28 b' class AdminRepoGroupsView(BaseAppView, D'
261
262
262 # perm check for admin, create_group perm or admin of parent_group
263 # perm check for admin, create_group perm or admin of parent_group
263 parent_group_id = safe_int(self.request.GET.get('parent_group'))
264 parent_group_id = safe_int(self.request.GET.get('parent_group'))
265 _gr = RepoGroup.get(parent_group_id)
264 if not self._can_create_repo_group(parent_group_id):
266 if not self._can_create_repo_group(parent_group_id):
265 raise HTTPForbidden()
267 raise HTTPForbidden()
266
268
267 self._load_form_data(c)
269 self._load_form_data(c)
268
270
269 defaults = {} # Future proof for default of repo group
271 defaults = {} # Future proof for default of repo group
272
273 parent_group_choice = '-1'
274 if not self._rhodecode_user.is_admin and self._rhodecode_user.personal_repo_group:
275 parent_group_choice = self._rhodecode_user.personal_repo_group
276
277 if parent_group_id and _gr:
278 if parent_group_id in [x[0] for x in c.repo_groups]:
279 parent_group_choice = safe_unicode(parent_group_id)
280
281 defaults.update({'group_parent_id': parent_group_choice})
282
270 data = render(
283 data = render(
271 'rhodecode:templates/admin/repo_groups/repo_group_add.mako',
284 'rhodecode:templates/admin/repo_groups/repo_group_add.mako',
272 self._get_template_context(c), self.request)
285 self._get_template_context(c), self.request)
286
273 html = formencode.htmlfill.render(
287 html = formencode.htmlfill.render(
274 data,
288 data,
275 defaults=defaults,
289 defaults=defaults,
@@ -169,8 +169,8 b' class AdminReposView(BaseAppView, DataGr'
169 c = self.load_default_context()
169 c = self.load_default_context()
170
170
171 new_repo = self.request.GET.get('repo', '')
171 new_repo = self.request.GET.get('repo', '')
172 parent_group = safe_int(self.request.GET.get('parent_group'))
172 parent_group_id = safe_int(self.request.GET.get('parent_group'))
173 _gr = RepoGroup.get(parent_group)
173 _gr = RepoGroup.get(parent_group_id)
174
174
175 if not HasPermissionAny('hg.admin', 'hg.create.repository')():
175 if not HasPermissionAny('hg.admin', 'hg.create.repository')():
176 # you're not super admin nor have global create permissions,
176 # you're not super admin nor have global create permissions,
@@ -196,9 +196,9 b' class AdminReposView(BaseAppView, DataGr'
196 if not self._rhodecode_user.is_admin and self._rhodecode_user.personal_repo_group:
196 if not self._rhodecode_user.is_admin and self._rhodecode_user.personal_repo_group:
197 parent_group_choice = self._rhodecode_user.personal_repo_group
197 parent_group_choice = self._rhodecode_user.personal_repo_group
198
198
199 if parent_group and _gr:
199 if parent_group_id and _gr:
200 if parent_group in [x[0] for x in c.repo_groups]:
200 if parent_group_id in [x[0] for x in c.repo_groups]:
201 parent_group_choice = safe_unicode(parent_group)
201 parent_group_choice = safe_unicode(parent_group_id)
202
202
203 defaults.update({'repo_group': parent_group_choice})
203 defaults.update({'repo_group': parent_group_choice})
204
204
@@ -45,6 +45,11 b''
45 </div>
45 </div>
46 <div class="select">
46 <div class="select">
47 ${h.select('group_parent_id',request.GET.get('parent_group'),c.repo_groups,class_="medium")}
47 ${h.select('group_parent_id', request.GET.get('parent_group'),c.repo_groups,class_="medium")}
48 % if c.personal_repo_group:
49 <a class="btn" href="#" id="select_my_group" data-personal-group-id="${c.personal_repo_group.group_id}">
50 ${_('Select my personal group ({})').format(c.personal_repo_group.group_name)}
51 </a>
52 % endif
48 </div>
53 </div>
49 </div>
54 </div>
50
55
@@ -106,6 +111,12 b''
106 setCopyPermsOption(e.val)
111 setCopyPermsOption(e.val)
107 });
112 });
108 $('#group_name').focus();
113 $('#group_name').focus();
114
115 $('#select_my_group').on('click', function(e){
116 e.preventDefault();
117 $("#group_parent_id").val($(this).data('personalGroupId')).trigger("change");
118 })
119
109 })
120 })
110 </script>
121 </script>
111 </%def>
122 </%def>
@@ -46,7 +46,7 b''
46 ${h.select('repo_group',request.GET.get('parent_group'),c.repo_groups,class_="medium")}
46 ${h.select('repo_group',request.GET.get('parent_group'),c.repo_groups,class_="medium")}
47 % if c.personal_repo_group:
47 % if c.personal_repo_group:
48 <a class="btn" href="#" id="select_my_group" data-personal-group-id="${c.personal_repo_group.group_id}">
48 <a class="btn" href="#" id="select_my_group" data-personal-group-id="${c.personal_repo_group.group_id}">
49 ${_('Select my personal group (%(repo_group_name)s)') % {'repo_group_name': c.personal_repo_group.group_name}}
49 ${_('Select my personal group ({})').format(c.personal_repo_group.group_name)}
50 </a>
50 </a>
51 % endif
51 % endif
52 <span class="help-block">${_('Optionally select a group to put this repository into.')}</span>
52 <span class="help-block">${_('Optionally select a group to put this repository into.')}</span>
General Comments 0
You need to be logged in to leave comments. Login now