Class: Katello::Api::V2::ErrataController

Inherits:
ApiController
  • Object
show all
Includes:
Concerns::Api::V2::RepositoryContentController
Defined in:
app/controllers/katello/api/v2/errata_controller.rb

Instance Method Summary collapse

Methods inherited from ApiController

#full_result_response, #resource_class, #scoped_search

Methods included from Rendering

#respond_for_async, #respond_for_bulk_async, #respond_for_create, #respond_for_destroy, #respond_for_index, #respond_for_show, #respond_for_status, #respond_for_update, #respond_with_template, #respond_with_template_collection, #respond_with_template_resource, #try_specific_collection_template, #try_specific_resource_template

Methods included from Katello::Api::Version2

#api_version

Instance Method Details

#available_for_content_view_filter(filter, collection) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 20

def available_for_content_view_filter(filter, collection)
  collection = filter_by_content_view(filter, collection)
  ids = Katello::ContentViewErratumFilterRule.where(:content_view_filter_id => filter.id).pluck("errata_id")
  collection = collection.where("errata_id not in (?)", ids) unless ids.empty?

  date_type = params[:date_type].present? ? params[:date_type] : ContentViewErratumFilterRule::UPDATED
  unless ContentViewErratumFilterRule::DATE_TYPES.include?(date_type)
    msg = _("Invalid params provided - date_type must be one of %s" % ContentViewErratumFilterRule::DATE_TYPES.join(","))
    fail HttpErrors::UnprocessableEntity, msg
  end

  collection = collection.where("#{date_type} >= ?", params[:start_date]) if params[:start_date]
  collection = collection.where("#{date_type} <= ?", params[:end_date]) if params[:end_date]
  collection = collection.of_type(params[:types]) if params[:types]
  collection
end

#custom_index_relation(collection) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 37

def custom_index_relation(collection)
  collection = filter_by_cve(params[:cve], collection) if params[:cve]
  hosts = ::Host::Managed.authorized("view_hosts")
  if ::Foreman::Cast.to_bool(params[:errata_restrict_applicable])
    collection = collection.applicable_to_hosts(hosts)
  end

  if ::Foreman::Cast.to_bool(params[:errata_restrict_installable])
    collection = collection.installable_for_hosts(hosts)
  end
  collection
end

#indexObject



16
17
18
# File 'app/controllers/katello/api/v2/errata_controller.rb', line 16

def index
  super
end