diff --git a/app/controllers/groups_controller.rb b/app/controllers/groups_controller.rb index 7c61ba41..6286639b 100755 --- a/app/controllers/groups_controller.rb +++ b/app/controllers/groups_controller.rb @@ -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 @@ -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 diff --git a/app/views/groups/show.html.slim b/app/views/groups/show.html.slim index e5d641ec..15ef0a56 100755 --- a/app/views/groups/show.html.slim +++ b/app/views/groups/show.html.slim @@ -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