Skip to content

Commit

Permalink
Updated 'find_checked_record_with_rbac' to accept array of ids
Browse files Browse the repository at this point in the history
  • Loading branch information
romanblanco committed Apr 3, 2017
1 parent a24949c commit bc791fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1392,8 +1392,8 @@ def find_checked_ids_with_rbac(klass, prefix = nil)
# Returns:
# array of records. If user does not have rigts for it,
# raises exception
def find_checked_records_with_rbac(klass)
ids = find_checked_items
def find_checked_records_with_rbac(klass, ids=nil)
ids ||= find_checked_items
filtered = Rbac.filtered(klass.where(:id => ids))
raise _("Unauthorized object or action") unless ids.length == filtered.length
filtered
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -707,9 +707,9 @@ def ot_copy_submit

def ot_remove_submit
assert_privileges("orchestration_template_remove")
checked = find_checked_ids_with_rbac(OrchestrationTemplate)
checked = find_checked_items
checked[0] = params[:id] if checked.blank? && params[:id]
elements = OrchestrationTemplate.where(:id => checked)
elements = find_checked_records_with_rbac(OrchestrationTemplate, checked)
elements.each do |ot|
if ot.in_use?
add_flash(_("Orchestration template \"%{name}\" is read-only and cannot be deleted.") %
Expand Down

0 comments on commit bc791fa

Please sign in to comment.