repo-permissions: add set/un-set of private repository from permissions page.
- this adds consistent 1way of controlling all permissiosn from permissions page - properly flushses caches on this change - adds better UX
This commit is contained in:
parent
616bbb0f5f
commit
6858bf047f
2 changed files with 14 additions and 6 deletions
|
|
@ -28,6 +28,7 @@ from rhodecode.lib import helpers as h
|
|||
from rhodecode.lib import audit_logger
|
||||
from rhodecode.lib.auth import (
|
||||
LoginRequired, HasRepoPermissionAnyDecorator, CSRFRequired)
|
||||
from rhodecode.lib.utils2 import str2bool
|
||||
from rhodecode.model.db import User
|
||||
from rhodecode.model.forms import RepoPermsForm
|
||||
from rhodecode.model.meta import Session
|
||||
|
|
@ -110,9 +111,11 @@ class RepoSettingsPermissionsView(RepoAppView):
|
|||
_ = self.request.translate
|
||||
self.load_default_context()
|
||||
|
||||
private_flag = str2bool(self.request.POST.get('private'))
|
||||
|
||||
try:
|
||||
RepoModel().update(
|
||||
self.db_repo, **{'repo_private': True, 'repo_name': self.db_repo_name})
|
||||
self.db_repo, **{'repo_private': private_flag, 'repo_name': self.db_repo_name})
|
||||
Session().commit()
|
||||
|
||||
h.flash(_('Repository `{}` private mode set successfully').format(self.db_repo_name),
|
||||
|
|
@ -128,5 +131,5 @@ class RepoSettingsPermissionsView(RepoAppView):
|
|||
|
||||
return {
|
||||
'redirect_url': h.route_path('edit_repo_perms', repo_name=self.db_repo_name),
|
||||
'private': True
|
||||
'private': private_flag
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,11 @@
|
|||
<td class="private_repo_msg">
|
||||
${base.gravatar(h.DEFAULT_USER_EMAIL, 16)}
|
||||
${h.DEFAULT_USER} - ${_('only users/user groups explicitly added here will have access')}</td>
|
||||
<td></td>
|
||||
<td class="td-action">
|
||||
<span class="tooltip btn btn-link btn-default" onclick="setPrivateRepo(false); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators. Default permissions wont apply')}">
|
||||
${_('un-set private mode')}
|
||||
</span>
|
||||
</td>
|
||||
<td class="quick_repo_menu">
|
||||
% if c.rhodecode_user.is_admin:
|
||||
<i class="icon-more"></i>
|
||||
|
|
@ -106,7 +110,7 @@
|
|||
${_('Remove')}
|
||||
</span>
|
||||
%elif _user.username == h.DEFAULT_USER:
|
||||
<span class="tooltip btn btn-link btn-default" onclick="enablePrivateRepo(); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators.')}">
|
||||
<span class="tooltip btn btn-link btn-default" onclick="setPrivateRepo(true); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators. Default permissions wont apply')}">
|
||||
${_('set private mode')}
|
||||
</span>
|
||||
%endif
|
||||
|
|
@ -204,9 +208,10 @@
|
|||
});
|
||||
quick_repo_menu();
|
||||
|
||||
var enablePrivateRepo = function () {
|
||||
var setPrivateRepo = function (private) {
|
||||
var postData = {
|
||||
'csrf_token': CSRF_TOKEN
|
||||
'csrf_token': CSRF_TOKEN,
|
||||
'private': private
|
||||
};
|
||||
|
||||
var success = function(o) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue