[refs #861] add product build lists api
This commit is contained in:
parent
75ea82d808
commit
18d61b4915
|
@ -0,0 +1,41 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
class Api::V1::ProductBuildListsController < Api::V1::BaseController
|
||||
before_filter :authenticate_user!
|
||||
skip_before_filter :authenticate_user!, :only => [:index, :show] if APP_CONFIG['anonymous_access']
|
||||
|
||||
load_and_authorize_resource :product, :only => :index
|
||||
load_and_authorize_resource :product_build_list
|
||||
|
||||
def index
|
||||
@product_build_lists = if @product
|
||||
@product.product_build_lists
|
||||
else
|
||||
ProductBuildList.accessible_by current_ability, :read
|
||||
end
|
||||
@product_build_lists = @product_build_lists.joins(:product, :project, :arch)
|
||||
@product_build_lists = @product_build_lists.recent.paginate(paginate_params)
|
||||
end
|
||||
|
||||
def create
|
||||
create_subject @product_build_list
|
||||
end
|
||||
|
||||
def update
|
||||
update_subject @product_build_list
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def destroy
|
||||
destroy_subject @product_build_list
|
||||
end
|
||||
|
||||
def cancel
|
||||
if @product_build_list.try(:can_cancel?) && @product_build_list.cancel
|
||||
render_json_response @product_build_list, t("layout.product_build_lists.cancel_success")
|
||||
else
|
||||
render_validation_error @product_build_list, t("layout.product_build_lists.cancel_fail")
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
json.(product_build_list, :id, :status, :time_living)
|
||||
json.notified_at product_build_list.updated_at
|
||||
json.url api_v1_product_build_list_path(product_build_list, :format => :json)
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
json.product_build_lists @product_build_lists do |json, product_build_list|
|
||||
json.partial! 'product_build_list', :product_build_list => product_build_list, :json => json
|
||||
end
|
||||
|
||||
json.url api_v1_product_build_lists_path(:format => :json)
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
json.product_build_list do |json|
|
||||
json.partial! 'product_build_list', :product_build_list => @product_build_list, :json => json
|
||||
json.(@product_build_list, :commit_hash, :main_script, :params)
|
||||
|
||||
json.product do |json_product|
|
||||
json.partial! 'api/v1/products/product',
|
||||
:product => @product_build_list.product, :json => json_product
|
||||
end
|
||||
|
||||
json.project do |json_project|
|
||||
json.partial! 'api/v1/projects/project',
|
||||
:project => @product_build_list.project, :json => json_project
|
||||
end
|
||||
|
||||
json.arch do |json_arch|
|
||||
json_arch.(@product_build_list.arch, :id, :name)
|
||||
end
|
||||
|
||||
json.created_at @product_build_list.created_at.to_i
|
||||
json.updated_at @product_build_list.updated_at.to_i
|
||||
|
||||
json.results (@product_build_list.results || []) do |json_logs, result|
|
||||
json_logs.file_name result['file_name']
|
||||
json_logs.size result['size']
|
||||
json_logs.url "#{APP_CONFIG['file_store_url']}/api/v1/file_stores/#{result['sha1']}"
|
||||
end
|
||||
end
|
|
@ -75,7 +75,12 @@ Rosa::Application.routes.draw do
|
|||
put :update_member
|
||||
}
|
||||
end
|
||||
resources :products, :only => [:show, :update, :create, :destroy]
|
||||
resources :products, :only => [:show, :update, :create, :destroy] do
|
||||
resources :product_build_lists, :only => :index
|
||||
end
|
||||
resources :product_build_lists do
|
||||
put :cancel, :on => :member
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue