permissions: fixed problem with permissions changes from permission page
This commit is contained in:
parent
6cf1c766fa
commit
212b05d88c
2 changed files with 21 additions and 9 deletions
|
|
@ -114,21 +114,26 @@ class RepoSettingsPermissionsView(RepoAppView):
|
|||
private_flag = str2bool(self.request.POST.get('private'))
|
||||
|
||||
try:
|
||||
RepoModel().update(
|
||||
self.db_repo, **{'repo_private': private_flag, 'repo_name': self.db_repo_name})
|
||||
repo = RepoModel().get(self.db_repo.repo_id)
|
||||
repo.private = private_flag
|
||||
Session().add(repo)
|
||||
RepoModel().grant_user_permission(
|
||||
repo=self.db_repo, user=User.DEFAULT_USER, perm='repository.none'
|
||||
)
|
||||
|
||||
Session().commit()
|
||||
|
||||
h.flash(_('Repository `{}` private mode set successfully').format(self.db_repo_name),
|
||||
category='success')
|
||||
# NOTE(dan): we change repo private mode we need to notify all USERS
|
||||
affected_user_ids = User.get_all_user_ids()
|
||||
PermissionModel().trigger_permission_flush(affected_user_ids)
|
||||
|
||||
except Exception:
|
||||
log.exception("Exception during update of repository")
|
||||
h.flash(_('Error occurred during update of repository {}').format(
|
||||
self.db_repo_name), category='error')
|
||||
|
||||
# NOTE(dan): we change repo private mode we need to notify all USERS
|
||||
affected_user_ids = User.get_all_user_ids()
|
||||
PermissionModel().trigger_permission_flush(affected_user_ids)
|
||||
|
||||
return {
|
||||
'redirect_url': h.route_path('edit_repo_perms', repo_name=self.db_repo_name),
|
||||
'private': private_flag
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
${base.gravatar(h.DEFAULT_USER_EMAIL, 16)}
|
||||
${h.DEFAULT_USER} - ${_('only users/user groups explicitly added here will have access')}</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')}">
|
||||
<span class="noselect tooltip btn btn-link btn-default" onclick="setPrivateRepo(this, 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>
|
||||
|
|
@ -115,7 +115,7 @@
|
|||
${_('Remove')}
|
||||
</span>
|
||||
%elif _user.username == h.DEFAULT_USER:
|
||||
<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')}">
|
||||
<span class="noselect tooltip btn btn-link btn-default" onclick="setPrivateRepo(this, true); return false" title="${_('Private repositories are only visible to people explicitly added as collaborators. Default permissions wont apply')}">
|
||||
${_('set private mode')}
|
||||
</span>
|
||||
%endif
|
||||
|
|
@ -213,7 +213,14 @@
|
|||
});
|
||||
quick_repo_menu();
|
||||
|
||||
var setPrivateRepo = function (private) {
|
||||
var setPrivateRepo = function (elem, private) {
|
||||
var $elem = $(elem)
|
||||
if ($elem.hasClass('disabled')) {
|
||||
return
|
||||
}
|
||||
$elem.addClass('disabled');
|
||||
$elem.css({"opacity": 0.3})
|
||||
|
||||
var postData = {
|
||||
'csrf_token': CSRF_TOKEN,
|
||||
'private': private
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue