Commit 02cf9aa6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Group owner or admin can remove other group owners

parent 8674e1c2
...@@ -19,7 +19,7 @@ class UsersGroupsController < ApplicationController ...@@ -19,7 +19,7 @@ class UsersGroupsController < ApplicationController
def destroy def destroy
@users_group = @group.users_groups.find(params[:id]) @users_group = @group.users_groups.find(params[:id])
@users_group.destroy unless @users_group.user == @group.owner @users_group.destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to members_group_path(@group), notice: 'User was successfully removed from group.' } format.html { redirect_to members_group_path(@group), notice: 'User was successfully removed from group.' }
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
%span.pull-right %span.pull-right
%strong= member.human_access %strong= member.human_access
- if show_controls && user != @group.owner && user != current_user - if show_controls && can?(current_user, :manage_group, @group) && current_user != user
= link_to '#', class: "btn-tiny btn js-toggle-button", title: 'Edit access level' do = link_to '#', class: "btn-tiny btn js-toggle-button", title: 'Edit access level' do
%i.icon-edit %i.icon-edit
= link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do = link_to group_users_group_path(@group, member), confirm: remove_user_from_group_message(@group, user), method: :delete, remote: true, class: "btn-tiny btn btn-remove", title: 'Remove user from group' do
...@@ -20,4 +20,4 @@ ...@@ -20,4 +20,4 @@
= form_for [@group, member], remote: true do |f| = form_for [@group, member], remote: true do |f|
.alert.prepend-top-20 .alert.prepend-top-20
= f.select :group_access, options_for_select(UsersGroup.group_access_roles, member.group_access) = f.select :group_access, options_for_select(UsersGroup.group_access_roles, member.group_access)
= f.submit 'Save', class: 'btn btn-save' = f.submit 'Save', class: 'btn btn-save btn-small'
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment