app/controllers/configuration_controller.rb
# Delete all selected or single displayed VM(s)
Delete all selected or single displayed VM(s)
Delete all selected or single displayed VM ( s )
def timeprofile_delete
    assert_privileges("tp_delete")
    timeprofiles = []
    unless params[:id] 
      timeprofiles = find_checked_items
      if timeprofiles.empty?
        add_flash(_("No %{records} were selected for deletion") %
          {:records => ui_lookup(:models => "TimeProfile")}, :error)
      else
        selected_timeprofiles = TimeProfile.where(:id => timeprofiles)
        selected_timeprofiles.each do |tp|
          if tp.description == "UTC"
            timeprofiles.delete(tp.id.to_s)
            add_flash(_("Default %{model} \"%{name}\" cannot be deleted") % {:model => ui_lookup(:model => "TimeProfile"), :name  => tp.description},
                      :error)
          elsif tp.profile_type == "global" && !admin_user?
            timeprofiles.delete(tp.id.to_s)
            add_flash(_("\"%{name}\": Global %{model} cannot be deleted") % {:name  => tp.description, :model => ui_lookup(:models => "TimeProfile")},
                      :error)
          elsif !tp.miq_reports.empty?
            timeprofiles.delete(tp.id.to_s)
            add_flash(_("\"%{name}\": In use by %{rep_count}, cannot be deleted") % {:name      => tp.description, :rep_count => pluralize(tp.miq_reports.count, "report")},
                      :error)
          end
        end
      end
      process_timeprofiles(timeprofiles, "destroy") unless timeprofiles.empty?
    end
    set_form_vars
  end
def timeprofile_delete assert_privileges ( "tp_delete" ) timeprofiles = [ ] unless params [ :id ] timeprofiles = find_checked_items if timeprofiles . empty? add_flash ( _ ( "No %{records} were selected for deletion" ) % { :records => ui_lookup ( :models => "TimeProfile" ) } , :error ) else selected_timeprofiles = TimeProfile . where ( :id => timeprofiles ) selected_timeprofiles . each do | tp | if tp . description == "UTC" timeprofiles . delete ( tp . id . to_s ) add_flash ( _ ( "Default %{model} \"%{name}\" cannot be deleted" ) % { :model => ui_lookup ( :model => "TimeProfile" ) , :name => tp . description } , :error ) elsif tp . profile_type == "global" && ! admin_user? timeprofiles . delete ( tp . id . to_s ) add_flash ( _ ( "\"%{name}\": Global %{model} cannot be deleted" ) % { :name => tp . description , :model => ui_lookup ( :models => "TimeProfile" ) } , :error ) elsif ! tp . miq_reports . empty? timeprofiles . delete ( tp . id . to_s ) add_flash ( _ ( "\"%{name}\": In use by %{rep_count}, cannot be deleted" ) % { :name => tp . description , :rep_count => pluralize ( tp . miq_reports . count , "report" ) } , :error ) end end end process_timeprofiles ( timeprofiles , "destroy" ) unless timeprofiles . empty? end set_form_vars end
Delete all selected or single displayed VM(s)
Delete all selected or single displayed VM ( s )
# showing a list, scan all selected timeprofiles