#859: update BuildList API
This commit is contained in:
parent
8677831e61
commit
2a1a15eb03
|
@ -15,26 +15,18 @@ class Api::V1::BuildListsController < Api::V1::BaseController
|
|||
|
||||
def create
|
||||
bl_params = params[:build_list] || {}
|
||||
project = Project.where(:id => bl_params[:project_id]).first
|
||||
save_to_repository = Repository.where(:id => bl_params[:save_to_repository_id]).first
|
||||
|
||||
if project && save_to_repository
|
||||
if save_to_repository
|
||||
bl_params[:save_to_platform_id] = save_to_repository.platform_id
|
||||
bl_params[:auto_publish] = false unless save_to_repository.publish_without_qa?
|
||||
end
|
||||
|
||||
@build_list = project.build_lists.build(bl_params)
|
||||
|
||||
@build_list = BuildList.new(bl_params)
|
||||
@build_list.user = current_user
|
||||
@build_list.priority = current_user.build_priority # User builds more priority than mass rebuild with zero priority
|
||||
|
||||
if @build_list.save
|
||||
render :action => 'show'
|
||||
else
|
||||
render :json => {:message => "Validation Failed", :errors => @build_list.errors.messages}.to_json, :status => 422
|
||||
end
|
||||
else
|
||||
render :json => {:message => "Bad Request"}.to_json, :status => 400
|
||||
end
|
||||
create_subject @build_list
|
||||
end
|
||||
|
||||
def cancel
|
||||
|
@ -49,17 +41,19 @@ class Api::V1::BuildListsController < Api::V1::BaseController
|
|||
render_json :reject_publish
|
||||
end
|
||||
|
||||
def create_container
|
||||
render_json :create_container
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def render_json(action_name)
|
||||
res, message = if !@build_list.send "can_#{action_name}?"
|
||||
[false, "Incorrect action for current build list"]
|
||||
if !@build_list.send "can_#{action_name}?"
|
||||
render_validation_error @build_list, "Incorrect action for current build list")
|
||||
elsif @build_list.send(action_name)
|
||||
[true, t("layout.build_lists.#{action_name}_success")]
|
||||
render_json_response @build_list, t("layout.build_lists.#{action_name}_success")
|
||||
else
|
||||
[false, t("layout.build_lists.#{action_name}_fail")]
|
||||
render_validation_error @build_list, t("layout.build_lists.#{action_name}_fail")
|
||||
end
|
||||
|
||||
render :json => {:"is_#{action_name}ed" => res, :url => api_v1_build_list_path(@build_list, :format => :json), :message => message}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -223,7 +223,9 @@ class BuildList < ActiveRecord::Base
|
|||
:do => :remove_container
|
||||
|
||||
event :publish_container do
|
||||
transition [:waiting_for_publish, :container_failed_publish] => :container_publish
|
||||
transition [:waiting_for_publish, :container_failed_publish] => :container_publish, :if => lambda { |build_list|
|
||||
build_list.success?
|
||||
}
|
||||
end
|
||||
|
||||
event :published_container do
|
||||
|
|
Loading…
Reference in New Issue