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
#compare ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/controllers/katello/concerns/api/v2/repository_content_controller.rb', line 55 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 collection = resource_class.all repos = Katello::Repository.where(:content_view_version_id => @versions.pluck(:id)) repos = repos.where(:library_instance_id => @repo.id) if @repo collection = scoped_search(filter_by_repos(repos, collection).uniq, default_sort[0], default_sort[1]) collection[:results] = collection[:results].map { |item| ContentViewVersionComparePresenter.new(item, @versions, @repo) } respond_for_index(:collection => collection) end |
#index ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/katello/concerns/api/v2/repository_content_controller.rb', line 30 def index = [] = {} if default_sort.is_a?(Array) = default_sort elsif default_sort.is_a?(Proc) [:custom_sort] = default_sort else fail "Unsupported default_sort type" end respond(:collection => scoped_search(index_relation.uniq, [0], [1], )) end |
#index_relation ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/katello/concerns/api/v2/repository_content_controller.rb', line 75 def index_relation collection = resource_class.all collection = filter_by_repos(Repository.readable, collection) collection = filter_by_repos([@repo], collection) if @repo collection = filter_by_content_view_version(@version, collection) if @version collection = filter_by_environment(@environment, collection) if @environment collection = filter_by_repos(Repository.readable.in_organization(@organization), collection) if @organization collection = filter_by_ids(params[:ids], collection) if params[:ids] @filter = ContentViewFilter.find(params[:filterId]) if params[:filterId] if params[:available_for] == "content_view_filter" && self.respond_to?(:available_for_content_view_filter) collection = self.available_for_content_view_filter(@filter, collection) if @filter else collection = filter_by_content_view_filter(@filter, collection) if @filter end collection = self.custom_index_relation(collection) if self.respond_to?(:custom_index_relation) collection end |
#show ⇒ Object
48 49 50 |
# File 'app/controllers/katello/concerns/api/v2/repository_content_controller.rb', line 48 def show respond :resource => @resource end |