app/controllers/application_controller.rb
# Common Saved Reports button handler routines
Common Saved Reports button handler routines
Common Saved Reports button handler routines
def process_saved_reports(saved_reports, task)
    success_count = 0
    failure_count = 0
    MiqReportResult.where(:id => saved_reports).order("lower(name)").each do |rep|
      begin
        rep.public_send(task) if rep.respond_to?(task) 
      rescue
        failure_count += 1  
      else
        if task == "destroy"
          AuditEvent.success(
            :event        => "rep_record_delete",
            :message      => "[#{rep.name}] Record deleted",
            :target_id    => rep.id,
            :target_class => "MiqReportResult",
            :userid       => current_userid
          )
          success_count += 1
        else
          add_flash(_("\"%{record}\": %{task} successfully initiated") % {:record => rep.name, :task => task})
        end
      end
    end
    if success_count > 0
      add_flash(n_("Successfully deleted Saved Report from the CFME Database",
                   "Successfully deleted Saved Reports from the CFME Database", success_count))
    end
    if failure_count > 0
      add_flash(n_("Error during Saved Report delete from the CFME Database",
                   "Error during Saved Reports delete from the CFME Database", failure_count))
    end
  end
def process_saved_reports ( saved_reports , task ) success_count = 0 failure_count = 0 MiqReportResult . where ( :id => saved_reports ) . order ( "lower(name)" ) . each do | rep | begin rep . public_send ( task ) if rep . respond_to? ( task ) rescue failure_count += 1 else if task == "destroy" AuditEvent . success ( :event => "rep_record_delete" , :message => "[#{rep.name}] Record deleted" , :target_id => rep . id , :target_class => "MiqReportResult" , :userid => current_userid ) success_count += 1 else add_flash ( _ ( "\"%{record}\": %{task} successfully initiated" ) % { :record => rep . name , :task => task } ) end end end if success_count > 0 add_flash ( n_ ( "Successfully deleted Saved Report from the CFME Database" , "Successfully deleted Saved Reports from the CFME Database" , success_count ) ) end if failure_count > 0 add_flash ( n_ ( "Error during Saved Report delete from the CFME Database" , "Error during Saved Reports delete from the CFME Database" , failure_count ) ) end end
Common Saved Reports button handler routines
Common Saved Reports button handler routines
# Run the task # Push msg and error flag
saved_reports
<not_specific>
task
<not_specific>