#671: added #members action for platforms API
This commit is contained in:
parent
abe31b3c2e
commit
9e6e2de955
|
@ -17,4 +17,8 @@ class Api::V1::BaseController < ApplicationController
|
|||
params[:per_page] = 100 if params[:per_page].to_i >100
|
||||
end
|
||||
|
||||
def paginate_params
|
||||
{:page => params[:page], :per_page => 20}
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -8,14 +8,14 @@ class Api::V1::PlatformsController < Api::V1::BaseController
|
|||
|
||||
def index
|
||||
@platforms = @platforms.accessible_by(current_ability, :related).
|
||||
by_type(params[:type]).paginate(:page => params[:page], :per_page => 20)
|
||||
by_type(params[:type]).paginate(paginate_params)
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def platforms_for_build
|
||||
@platforms = Platform.main.opened.paginate(:page => params[:page], :per_page => 20)
|
||||
@platforms = Platform.main.opened.paginate(paginate_params)
|
||||
render :index
|
||||
end
|
||||
|
||||
|
@ -36,4 +36,8 @@ class Api::V1::PlatformsController < Api::V1::BaseController
|
|||
end
|
||||
end
|
||||
|
||||
def members
|
||||
@members = @platform.members.order('name').paginate(paginate_params)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
json.platform do |json|
|
||||
json.(@platform, :id)
|
||||
json.members @members do |json_members, member|
|
||||
json_members.(member, :id)
|
||||
json_members.type member.class.name
|
||||
end
|
||||
end
|
||||
json.url members_api_v1_platform_path(@platform, :format => :json)
|
|
@ -20,8 +20,13 @@ Rosa::Application.routes.draw do
|
|||
}
|
||||
end
|
||||
resources :arches, :only => [:index]
|
||||
resources :platforms, :only => [:index, :show] do
|
||||
collection { get :platforms_for_build }
|
||||
resources :platforms, :only => [:index, :show, :update] do
|
||||
collection {
|
||||
get :platforms_for_build
|
||||
}
|
||||
member {
|
||||
get :members
|
||||
}
|
||||
end
|
||||
resources :repositories, :only => [:show]
|
||||
resources :projects, :only => [:show] do
|
||||
|
|
Loading…
Reference in New Issue