Module: Katello::Api::V2::RepositoryContentController

Extended by:
ActiveSupport::Concern, Apipie::DSL::Concern
Defined in:
app/controllers/katello/concerns/api/v2/repository_content_controller.rb

Instance Method Summary collapse

Instance Method Details

#compareObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/controllers/katello/concerns/api/v2/repository_content_controller.rb', line 54

def compare
  fail _("No content_view_version_ids provided") if params[:content_view_version_ids].empty?
  @versions = ContentViewVersion.readable.where(:id => params[:content_view_version_ids])
  if @versions.count != params[:content_view_version_ids].uniq.length
    missing = params[:content_view_version_ids] - @versions.pluck(:id)
    fail HttpErrors::NotFound, _("Couldn't find content view versions '%s'") % missing.join(',')
  end

  sort_by, sort_order, options = sort_options

  if respond_to?(:custom_collection_by_content_view_version)
    collection = custom_collection_by_content_view_version(@versions)
  else
    repos = Katello::Repository.where(:content_view_version_id => @versions.pluck(:id))
    repos = repos.where(:root_id => @repo.root_id) if @repo
    collection = filter_by_repos(repos, resource_class.all, @versions, params[:restrict_comparison])
  end
  collection = scoped_search(collection.distinct, sort_by, sort_order, options)
  collection[:results] = collection[:results].map { |item| ContentViewVersionComparePresenter.new(item, @versions, @repo) }
  respond_for_index(:collection => collection)
end

#indexObject



34
35
36
37
# File 'app/controllers/katello/concerns/api/v2/repository_content_controller.rb', line 34

def index
  sort_by, sort_order, options = sort_options
  respond(:collection => scoped_search(index_relation, sort_by, sort_order, options))
end

#index_relationObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'app/controllers/katello/concerns/api/v2/repository_content_controller.rb', line 81

def index_relation
  if @version && params[:available_for] == "content_view_version" && self.respond_to?(:available_for_content_view_version)
    collection = self.available_for_content_view_version(@version)
  else
    collection = resource_class.all
    collection = filter_by_content_view_version(@version, collection) if @version
  end

  collection = filter_by_repos(repos, collection)
  collection = filter_by_ids(params[:ids], collection) if params[:ids]
  collection = handle_cv_filter(collection, @filter, @filter_rule, params) if @filter || @filter_rule

  collection = self.custom_index_relation(collection) if self.respond_to?(:custom_index_relation)
  collection
end

#showObject



45
46
47
# File 'app/controllers/katello/concerns/api/v2/repository_content_controller.rb', line 45

def show
  respond :resource => @resource
end