From 36b258d2a04524f8acbe5e868c228251f3c74365 Mon Sep 17 00:00:00 2001 From: Alexander Machehin Date: Fri, 1 Feb 2013 21:52:41 +0600 Subject: [PATCH] [refs #861] move products list to platform --- app/controllers/api/v1/products_controller.rb | 8 +------- app/views/api/v1/platforms/show.json.jbuilder | 5 ++++- app/views/api/v1/products/index.json.jbuilder | 9 --------- config/routes.rb | 1 - 4 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 app/views/api/v1/products/index.json.jbuilder diff --git a/app/controllers/api/v1/products_controller.rb b/app/controllers/api/v1/products_controller.rb index 8953d3186..3b82cd085 100644 --- a/app/controllers/api/v1/products_controller.rb +++ b/app/controllers/api/v1/products_controller.rb @@ -3,13 +3,7 @@ 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 + load_and_authorize_resource def create create_subject @product diff --git a/app/views/api/v1/platforms/show.json.jbuilder b/app/views/api/v1/platforms/show.json.jbuilder index c8c90a945..a9fd620bc 100644 --- a/app/views/api/v1/platforms/show.json.jbuilder +++ b/app/views/api/v1/platforms/show.json.jbuilder @@ -8,4 +8,7 @@ json.platform do |json| json_repos.(repo, :id, :name) json_repos.url api_v1_repository_path(repo.id, :format => :json) end -end \ No newline at end of file + json.products @platform.products do |json_products, product| + json.partial! 'api/v1/products/product', :product => product, :json => json_products + end +end diff --git a/app/views/api/v1/products/index.json.jbuilder b/app/views/api/v1/products/index.json.jbuilder deleted file mode 100644 index eee8958e5..000000000 --- a/app/views/api/v1/products/index.json.jbuilder +++ /dev/null @@ -1,9 +0,0 @@ -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) diff --git a/config/routes.rb b/config/routes.rb index 09e4f3067..47065e7e5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,7 +35,6 @@ Rosa::Application.routes.draw do put :clear } resources :maintainers, :only => [ :index ] - resources :products, :only => :index end resources :repositories, :only => [:show, :update, :destroy] do member {