Skip to content

Commit

Permalink
Add RBAC for users and role in widgets
Browse files Browse the repository at this point in the history
  • Loading branch information
lpichler committed Apr 3, 2017
1 parent 798ca9a commit 9349735
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions app/controllers/report_controller/widgets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,13 @@ def widget_get_node_info
if @widget.visibility && @widget.visibility[:roles]
@sb[:user_roles] = []
if @widget.visibility[:roles][0] != "_ALL_"
MiqUserRole.all.sort_by(&:name).each do |r|
Rbac.filtered(MiqUserRole).sort_by(&:name).each do |r|
@sb[:user_roles].push(r.name) if @widget.visibility[:roles].include?(r.name)
end
end
elsif @widget.visibility && @widget.visibility[:groups]
@sb[:groups] = []
MiqGroup.non_tenant_groups_in_my_region.sort_by(&:description).each do |r|
Rbac.filtered(MiqGroup.non_tenant_groups_in_my_region).sort_by(&:description).each do |r|
@sb[:groups].push(r.description) if @widget.visibility[:groups].include?(r.description)
end
end
Expand Down Expand Up @@ -329,21 +329,21 @@ def widget_set_form_vars
if @widget.visibility[:roles][0] == "_ALL_"
@edit[:new][:roles] = ["_ALL_"]
else
roles = MiqUserRole.where(:name => @widget.visibility[:roles])
roles = Rbac.filtered(MiqUserRole.where(:name => @widget.visibility[:roles]))
@edit[:new][:roles] = roles.collect { |role| to_cid(role.id) }.sort
end
elsif @widget.visibility[:groups]
@edit[:new][:visibility_typ] = "group"
groups = MiqGroup.in_my_region.where(:description => @widget.visibility[:groups])
groups = Rbac.filtered(MiqGroup.in_my_region.where(:description => @widget.visibility[:groups]))
@edit[:new][:groups] = groups.collect { |group| to_cid(group.id) }.sort
end
end
@edit[:sorted_user_roles] =
MiqUserRole.all.sort_by { |r| r.name.downcase }
Rbac.filtered(MiqUserRole).sort_by { |r| r.name.downcase }
.collect { |r| {r.name => to_cid(r.id)} }

@edit[:sorted_groups] =
MiqGroup.non_tenant_groups_in_my_region.sort_by { |g| g.description.downcase }
Rbac.filtered(MiqGroup.non_tenant_groups_in_my_region).sort_by { |g| g.description.downcase }
.collect { |g| {g.description => to_cid(g.id)} }

# Schedule Box - create new sched for copy/new, use existing for edit
Expand Down

0 comments on commit 9349735

Please sign in to comment.