Class: ArfReportsController

Inherits:
ApplicationController
  • Object
show all
Includes:
Foreman::Controller::AutoCompleteSearch, ForemanOpenscap::ArfReportsControllerCommonExtensions
Defined in:
app/controllers/arf_reports_controller.rb

Instance Method Summary collapse

Methods included from ForemanOpenscap::ArfReportsControllerCommonExtensions

#format_filename

Instance Method Details

#delete_multipleObject



61
62
# File 'app/controllers/arf_reports_controller.rb', line 61

def delete_multiple
end

#destroyObject



53
54
55
56
57
58
59
# File 'app/controllers/arf_reports_controller.rb', line 53

def destroy
  if @arf_report.destroy
    process_success(:success_msg => _("Successfully deleted ARF report."), :success_redirect => arf_reports_path)
  else
    process_error(:error_msg => _("Failed to delete ARF Report for host %{host_name} reported at %{reported_at}") % { :host_name => @arf_report.host.name, :reported_at => @arf_report.reported_at })
  end
end

#download_htmlObject



42
43
44
45
46
47
48
49
50
51
# File 'app/controllers/arf_reports_controller.rb', line 42

def download_html
  begin
    response = @arf_report.to_html
    send_data response, :filename => "#{format_filename}.html",
                        :type => 'text/html', :disposition => 'attachement'
  rescue => e
    process_error(:error_msg => _("Failed to downloaded ARF report in HTML: %s") % e.message,
                  :error_redirect => arf_report_path(@arf_report.id))
  end
end

#indexObject



12
13
14
15
16
# File 'app/controllers/arf_reports_controller.rb', line 12

def index
  @arf_reports = resource_base.includes(:policy, :openscap_proxy, :host => %i[policies last_report_object host_statuses])
                              .search_for(params[:search], :order => params[:order])
                              .paginate(:page => params[:page], :per_page => params[:per_page])
end

#model_of_controllerObject



8
9
10
# File 'app/controllers/arf_reports_controller.rb', line 8

def model_of_controller
  ::ForemanOpenscap::ArfReport
end

#parse_bzipObject



32
33
34
35
36
37
38
39
40
# File 'app/controllers/arf_reports_controller.rb', line 32

def parse_bzip
  begin
    response = @arf_report.to_bzip
    send_data response, :filename => "#{format_filename}.xml.bz2", :type => 'application/octet-stream', :disposition => 'attachement'
  rescue => e
    process_error(:error_msg => (_("Failed to downloaded ARF report as bzip: %s") % e.message),
                  :error_redirect => arf_report_path(@arf_report.id))
  end
end

#parse_htmlObject



24
25
26
27
28
29
30
# File 'app/controllers/arf_reports_controller.rb', line 24

def parse_html
  begin
    self.response_body = @arf_report.to_html
  rescue => e
    render :plain => _(e.message)
  end
end

#showObject



18
19
# File 'app/controllers/arf_reports_controller.rb', line 18

def show
end

#show_htmlObject



21
22
# File 'app/controllers/arf_reports_controller.rb', line 21

def show_html
end

#submit_delete_multipleObject



64
65
66
67
68
69
70
71
72
73
# File 'app/controllers/arf_reports_controller.rb', line 64

def submit_delete_multiple
  failed_deletes = @arf_reports.reject(&:destroy).count
  if failed_deletes > 0
    process_error(:error_msg => (_("Failed to delete %s compliance reports") % failed_deletes),
                  :error_redirect => arf_reports_path)
  else
    process_success(:success_msg => (_("Successfully deleted %s compliance reports") % @arf_reports.size),
                    :success_redirect => arf_reports_path)
  end
end