[refs #861] add products api
This commit is contained in:
parent
3f3edfe1d9
commit
94401d4494
|
@ -0,0 +1,28 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class Api::V1::ProductsController < Api::V1::BaseController
|
||||
before_filter :authenticate_user!
|
||||
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
|
||||
|
||||
load_and_authorize_resource :platform, :only => :index
|
||||
#load_and_authorize_resource :product, :through => :platform, :only => :index
|
||||
load_and_authorize_resource :only => [:show, :edit, :update, :destroy, :create]
|
||||
|
||||
def index
|
||||
@products = @platform.products.paginate(paginate_params)
|
||||
end
|
||||
|
||||
def create
|
||||
create_subject @product
|
||||
end
|
||||
|
||||
def update
|
||||
update_subject @product
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def destroy
|
||||
destroy_subject @product
|
||||
end
|
||||
end
|
|
@ -0,0 +1 @@
|
|||
json.(product, :id, :name, :description, :main_script, :params, :time_living)
|
|
@ -0,0 +1,9 @@
|
|||
json.platform do |json_platform|
|
||||
json.partial! 'api/v1/platforms/platform', :platform => @platform, :json => json_platform
|
||||
end
|
||||
|
||||
json.products @products do |json, product|
|
||||
json.partial! 'product', :product => product, :json => json
|
||||
end
|
||||
|
||||
json.url api_v1_products_path(@platform.id, :format => :json)
|
|
@ -0,0 +1,13 @@
|
|||
json.product do |json|
|
||||
json.partial! 'product', :product => @product, :json => json
|
||||
json.platform do |json_platform|
|
||||
json.partial! 'api/v1/platforms/platform', :platform => @product.platform, :json => json_platform
|
||||
end
|
||||
if @product.project.present?
|
||||
json.project do |json_project|
|
||||
json.partial! 'api/v1/projects/project', :project => @product.project, :json => json_project
|
||||
end
|
||||
end
|
||||
json.created_at @product.created_at.to_i
|
||||
json.updated_at @product.updated_at.to_i
|
||||
end
|
|
@ -35,6 +35,7 @@ Rosa::Application.routes.draw do
|
|||
put :clear
|
||||
}
|
||||
resources :maintainers, :only => [ :index ]
|
||||
resources :products, :only => :index
|
||||
end
|
||||
resources :repositories, :only => [:show, :update, :destroy] do
|
||||
member {
|
||||
|
@ -75,6 +76,7 @@ Rosa::Application.routes.draw do
|
|||
put :update_member
|
||||
}
|
||||
end
|
||||
resources :products, :only => [:show, :update, :create, :destroy]
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue