diff --git a/rhodecode/apps/repository/views/repo_permissions.py b/rhodecode/apps/repository/views/repo_permissions.py --- a/rhodecode/apps/repository/views/repo_permissions.py +++ b/rhodecode/apps/repository/views/repo_permissions.py @@ -114,21 +114,26 @@ class RepoSettingsPermissionsView(RepoAp 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 diff --git a/rhodecode/templates/admin/repos/repo_edit_permissions.mako b/rhodecode/templates/admin/repos/repo_edit_permissions.mako --- a/rhodecode/templates/admin/repos/repo_edit_permissions.mako +++ b/rhodecode/templates/admin/repos/repo_edit_permissions.mako @@ -59,7 +59,7 @@ ${base.gravatar(h.DEFAULT_USER_EMAIL, 16)} ${h.DEFAULT_USER} - ${_('only users/user groups explicitly added here will have access')}