Skip to content

Commit

Permalink
only site-wide admin / super admin can manage group admins
Browse files Browse the repository at this point in the history
  • Loading branch information
giosakti committed Dec 16, 2018
1 parent f011fae commit aabe263
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions app/controllers/groups_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def add_machine
end

def add_admin
if current_user.admin? or @group.admin?(current_user)
if current_user.admin?
GroupAdmin.find_or_create_by(group_id: @group.id, user_id: params[:user_id])
end

Expand All @@ -109,7 +109,7 @@ def add_admin
end

def remove_admin
if current_user.admin? or @group.admin?(current_user)
if current_user.admin?
GroupAdmin.delete(params[:group_admin_id])
end

Expand Down
25 changes: 13 additions & 12 deletions app/views/groups/show.html.slim
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@
.col
= "#{admin.user.try(:name)}"
.col
- if (current_user.admin? or @group.admin?(current_user) ) and current_user.id != admin.user.try(:id)
= link_to "Remove?", [@group, admin], method: :delete, data: {confirm: "Are you sure to remove #{admin.user.try(:name)} ?"}
.row
.col
= text_field_tag "user_id", "", id: "assign_admin_user_id", class: "form-control"
.col
= submit_tag "Assign admin", class: "form-control btn btn-md btn-primary", disabled: true
.row
.col
= check_box_tag "assign_admin_include_inactive_user", "true", false
= " Include Inactive User"
.col
- if (current_user.admin?)
= link_to "Remove?", [@group, admin], method: :delete, data: {confirm: "Are you sure to remove #{admin.user.try(:name)} ?"}
- if (current_user.admin?)
.row
.col
= text_field_tag "user_id", "", id: "assign_admin_user_id", class: "form-control"
.col
= submit_tag "Assign admin", class: "form-control btn btn-md btn-primary", disabled: true
.row
.col
= check_box_tag "assign_admin_include_inactive_user", "true", false
= " Include Inactive User"
.col
a name="group_members"
br
.card
Expand Down

0 comments on commit aabe263

Please sign in to comment.