Skip to content

Commit

Permalink
Merge pull request #1136 from isimluk/rhbz#1442691
Browse files Browse the repository at this point in the history
Find correct klass for rbac check for `retirevms`
(cherry picked from commit d7743ae)

https://bugzilla.redhat.com/show_bug.cgi?id=1445283
  • Loading branch information
martinpovolny authored and simaishi committed Apr 25, 2017
1 parent ad2bc25 commit cbc9d43
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions app/controllers/application_controller/ci_processing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -215,15 +215,7 @@ def ownership_update
# Retire 1 or more items (vms, stacks, services)
def retirevms
assert_privileges(params[:pressed])
klass = get_class_from_controller_param(params[:controller])
selected_items = find_checked_ids_with_rbac(klass)
if !%w(orchestration_stack service).include?(request.parameters["controller"]) && !%w(orchestration_stacks).include?(params[:display]) &&
VmOrTemplate.find(selected_items).any? { |vm| !vm.supports_retire? }
add_flash(_("Set Retirement Date does not apply to selected %{model}") %
{:model => ui_lookup(:table => "miq_template")}, :error)
javascript_flash(:scroll_top => true)
return
end

# check to see if coming from show_list or drilled into vms from another CI
if request.parameters[:controller] == "vm" || %w(all_vms instances vms).include?(params[:display])
rec_cls = "vm"
Expand All @@ -235,6 +227,15 @@ def retirevms
rec_cls = "orchestration_stack"
bc_msg = _("Retire Orchestration Stack")
end
klass = rec_cls ? rec_cls.camelize.constantize : get_class_from_controller_param(params[:controller])
selected_items = find_checked_ids_with_rbac(klass)
if !%w(orchestration_stack service).include?(request.parameters["controller"]) && !%w(orchestration_stacks).include?(params[:display]) &&
VmOrTemplate.find(selected_items).any? { |vm| !vm.supports_retire? }
add_flash(_("Set Retirement Date does not apply to selected %{model}") %
{:model => ui_lookup(:table => "miq_template")}, :error)
javascript_flash(:scroll_top => true)
return
end
if selected_items.blank?
session[:retire_items] = [params[:id]]
elsif selected_items.empty?
Expand Down

0 comments on commit cbc9d43

Please sign in to comment.