##// END OF EJS Templates
permissions: fixed problem with permissions changes from permission page
marcink -
r4334:b3a3408e default
parent child Browse files
Show More
@@ -114,21 +114,26 b' class RepoSettingsPermissionsView(RepoAp'
114 private_flag = str2bool(self.request.POST.get('private'))
114 private_flag = str2bool(self.request.POST.get('private'))
115
115
116 try:
116 try:
117 RepoModel().update(
117 repo = RepoModel().get(self.db_repo.repo_id)
118 self.db_repo, **{'repo_private': private_flag, 'repo_name': self.db_repo_name})
118 repo.private = private_flag
119 Session().add(repo)
120 RepoModel().grant_user_permission(
121 repo=self.db_repo, user=User.DEFAULT_USER, perm='repository.none'
122 )
123
119 Session().commit()
124 Session().commit()
120
125
121 h.flash(_('Repository `{}` private mode set successfully').format(self.db_repo_name),
126 h.flash(_('Repository `{}` private mode set successfully').format(self.db_repo_name),
122 category='success')
127 category='success')
128 # NOTE(dan): we change repo private mode we need to notify all USERS
129 affected_user_ids = User.get_all_user_ids()
130 PermissionModel().trigger_permission_flush(affected_user_ids)
131
123 except Exception:
132 except Exception:
124 log.exception("Exception during update of repository")
133 log.exception("Exception during update of repository")
125 h.flash(_('Error occurred during update of repository {}').format(
134 h.flash(_('Error occurred during update of repository {}').format(
126 self.db_repo_name), category='error')
135 self.db_repo_name), category='error')
127
136
128 # NOTE(dan): we change repo private mode we need to notify all USERS
129 affected_user_ids = User.get_all_user_ids()
130 PermissionModel().trigger_permission_flush(affected_user_ids)
131
132 return {
137 return {
133 'redirect_url': h.route_path('edit_repo_perms', repo_name=self.db_repo_name),
138 'redirect_url': h.route_path('edit_repo_perms', repo_name=self.db_repo_name),
134 'private': private_flag
139 'private': private_flag
@@ -59,7 +59,7 b''
59 ${base.gravatar(h.DEFAULT_USER_EMAIL, 16)}
59 ${base.gravatar(h.DEFAULT_USER_EMAIL, 16)}
60 ${h.DEFAULT_USER} - ${_('only users/user groups explicitly added here will have access')}</td>
60 ${h.DEFAULT_USER} - ${_('only users/user groups explicitly added here will have access')}</td>
61 <td class="td-action">
61 <td class="td-action">
62 <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')}">
62 <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')}">
63 ${_('un-set private mode')}
63 ${_('un-set private mode')}
64 </span>
64 </span>
65 </td>
65 </td>
@@ -115,7 +115,7 b''
115 ${_('Remove')}
115 ${_('Remove')}
116 </span>
116 </span>
117 %elif _user.username == h.DEFAULT_USER:
117 %elif _user.username == h.DEFAULT_USER:
118 <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')}">
118 <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')}">
119 ${_('set private mode')}
119 ${_('set private mode')}
120 </span>
120 </span>
121 %endif
121 %endif
@@ -213,7 +213,14 b''
213 });
213 });
214 quick_repo_menu();
214 quick_repo_menu();
215
215
216 var setPrivateRepo = function (private) {
216 var setPrivateRepo = function (elem, private) {
217 var $elem = $(elem)
218 if ($elem.hasClass('disabled')) {
219 return
220 }
221 $elem.addClass('disabled');
222 $elem.css({"opacity": 0.3})
223
217 var postData = {
224 var postData = {
218 'csrf_token': CSRF_TOKEN,
225 'csrf_token': CSRF_TOKEN,
219 'private': private
226 'private': private
General Comments 0
You need to be logged in to leave comments. Login now