##// END OF EJS Templates
repository-permissions: enable shortcut to set private mode in permission page.
ergo -
r3809:d49b6555 stable
parent child Browse files
Show More
@@ -369,6 +369,10 b' def includeme(config):'
369 name='edit_repo_perms',
369 name='edit_repo_perms',
370 pattern='/{repo_name:.*?[^/]}/settings/permissions', repo_route=True)
370 pattern='/{repo_name:.*?[^/]}/settings/permissions', repo_route=True)
371
371
372 config.add_route(
373 name='edit_repo_perms_set_private',
374 pattern='/{repo_name:.*?[^/]}/settings/permissions/set_private', repo_route=True)
375
372 # Permissions Branch (EE feature)
376 # Permissions Branch (EE feature)
373 config.add_route(
377 config.add_route(
374 name='edit_repo_perms_branch',
378 name='edit_repo_perms_branch',
@@ -105,3 +105,30 b' class RepoSettingsPermissionsView(RepoAp'
105
105
106 raise HTTPFound(
106 raise HTTPFound(
107 h.route_path('edit_repo_perms', repo_name=self.db_repo_name))
107 h.route_path('edit_repo_perms', repo_name=self.db_repo_name))
108
109 @LoginRequired()
110 @HasRepoPermissionAnyDecorator('repository.admin')
111 @CSRFRequired()
112 @view_config(
113 route_name='edit_repo_perms_set_private', request_method='POST',
114 renderer='json_ext')
115 def edit_permissions_set_private_repo(self):
116 _ = self.request.translate
117 self.load_default_context()
118
119 try:
120 RepoModel().update(
121 self.db_repo, **{'repo_private': True, 'repo_name': self.db_repo_name})
122 Session().commit()
123
124 h.flash(_('Repository `{}` private mode set successfully').format(self.db_repo_name),
125 category='success')
126 except Exception:
127 log.exception("Exception during update of repository")
128 h.flash(_('Error occurred during update of repository {}').format(
129 self.db_repo_name), category='error')
130
131 return {
132 'redirect_url': h.route_path('edit_repo_perms', repo_name=self.db_repo_name),
133 'private': True
134 }
@@ -374,8 +374,7 b' class RepoModel(BaseModel):'
374 )
374 )
375
375
376 # handle extra fields
376 # handle extra fields
377 for field in filter(lambda k: k.startswith(RepositoryField.PREFIX),
377 for field in filter(lambda k: k.startswith(RepositoryField.PREFIX), kwargs):
378 kwargs):
379 k = RepositoryField.un_prefix_key(field)
378 k = RepositoryField.un_prefix_key(field)
380 ex_field = RepositoryField.get_by_key_name(
379 ex_field = RepositoryField.get_by_key_name(
381 key=k, repo=cur_repo)
380 key=k, repo=cur_repo)
@@ -239,6 +239,7 b' function registerRCRoutes() {'
239 pyroutes.register('edit_repo_advanced_hooks', '/%(repo_name)s/settings/advanced/hooks', ['repo_name']);
239 pyroutes.register('edit_repo_advanced_hooks', '/%(repo_name)s/settings/advanced/hooks', ['repo_name']);
240 pyroutes.register('edit_repo_caches', '/%(repo_name)s/settings/caches', ['repo_name']);
240 pyroutes.register('edit_repo_caches', '/%(repo_name)s/settings/caches', ['repo_name']);
241 pyroutes.register('edit_repo_perms', '/%(repo_name)s/settings/permissions', ['repo_name']);
241 pyroutes.register('edit_repo_perms', '/%(repo_name)s/settings/permissions', ['repo_name']);
242 pyroutes.register('edit_repo_perms_set_private', '/%(repo_name)s/settings/permissions/set_private', ['repo_name']);
242 pyroutes.register('edit_repo_maintenance', '/%(repo_name)s/settings/maintenance', ['repo_name']);
243 pyroutes.register('edit_repo_maintenance', '/%(repo_name)s/settings/maintenance', ['repo_name']);
243 pyroutes.register('edit_repo_maintenance_execute', '/%(repo_name)s/settings/maintenance/execute', ['repo_name']);
244 pyroutes.register('edit_repo_maintenance_execute', '/%(repo_name)s/settings/maintenance/execute', ['repo_name']);
244 pyroutes.register('edit_repo_fields', '/%(repo_name)s/settings/fields', ['repo_name']);
245 pyroutes.register('edit_repo_fields', '/%(repo_name)s/settings/fields', ['repo_name']);
@@ -105,6 +105,10 b''
105 member="${_user.user_id}" member_type="user">
105 member="${_user.user_id}" member_type="user">
106 ${_('Remove')}
106 ${_('Remove')}
107 </span>
107 </span>
108 %elif _user.username == h.DEFAULT_USER:
109 <span class="tooltip btn btn-link btn-default" onclick="enablePrivateRepo(); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators.')}">
110 ${_('set private mode')}
111 </span>
108 %endif
112 %endif
109 </td>
113 </td>
110 <td class="quick_repo_menu">
114 <td class="quick_repo_menu">
@@ -199,4 +203,20 b''
199 markRevokePermInput($(this), 'repository');
203 markRevokePermInput($(this), 'repository');
200 });
204 });
201 quick_repo_menu();
205 quick_repo_menu();
206
207 var enablePrivateRepo = function () {
208 var postData = {
209 'csrf_token': CSRF_TOKEN
210 };
211
212 var success = function(o) {
213 var defaultUrl = pyroutes.url('edit_repo_perms', {"repo_name": templateContext.repo_name});
214 window.location = o.redirect_url || defaultUrl;
215 };
216
217 ajaxPOST(
218 pyroutes.url('edit_repo_perms_set_private', {"repo_name": templateContext.repo_name}),
219 postData,
220 success);
221 }
202 </script>
222 </script>
General Comments 0
You need to be logged in to leave comments. Login now