Project

General

Profile

Revision 40825a11

Added by Marek Hulán over 4 years ago

Fixes #21893 - fix listing containers for specific CR

View differences:

app/controllers/api/v2/containers_controller.rb
17 17
      param_group :search_and_pagination, ::Api::V2::BaseController
18 18

  
19 19
      def index
20
        compute_resource_id = params[:compute_resource_id].tap do |id|
21
          id.present? ? { :compute_resource_id => id } : nil
22
        end
23
        scoped = Container.where(compute_resource_id)
24
        @containers = scoped.search_for(params[:search], :order => params[:order])
20
        scope = resource_scope
21
        scope = scope.where(:compute_resource => params[:compute_resource_id]) if params[:compute_resource_id].present?
22
        @containers = scope.search_for(params[:search], :order => params[:order])
25 23
                      .paginate(:page => params[:page])
26 24
      end
27 25

  
app/controllers/containers_controller.rb
100 100

  
101 101
  def container_deletion
102 102
    # TODO: Refactor to recognize params[:compute_resource_id] as well.
103
    compute_resource_id = params[:compute_resource_id].tap { |id| id.present? ? id : nil }
103
    compute_resource_id = params[:compute_resource_id].present? ? params[:compute_resource_id] : nil 
104 104
    if compute_resource_id
105 105
      container_uuid = params[:id]
106 106
      @container ||= Container.authorized("#{action_permission}_#{controller_name}".to_sym).find_by_uuid(container_uuid)

Also available in: Unified diff