2012-07-04 13:15:12 +01:00
|
|
|
#class MassBuildsController < ApplicationController
|
|
|
|
class Platforms::MassBuildsController < Platforms::BaseController
|
2012-07-02 15:50:47 +01:00
|
|
|
before_filter :authenticate_user!
|
|
|
|
|
2012-07-03 15:34:07 +01:00
|
|
|
load_and_authorize_resource :platform
|
2012-07-02 15:50:47 +01:00
|
|
|
load_and_authorize_resource
|
|
|
|
|
2012-07-03 15:34:07 +01:00
|
|
|
skip_load_and_authorize_resource :only => [:index, :create]
|
2013-03-21 14:41:45 +00:00
|
|
|
skip_load_and_authorize_resource :platform, :only => [:cancel, :failed_builds_list, :publish]
|
|
|
|
skip_authorize_resource :platform, :only => [:index, :create]
|
2012-07-03 15:34:07 +01:00
|
|
|
|
|
|
|
def create
|
2012-12-10 19:35:56 +00:00
|
|
|
mass_build = @platform.mass_builds.new(:arches => params[:arches],
|
2012-12-06 17:59:17 +00:00
|
|
|
:auto_publish => params[:auto_publish] || false,
|
2013-01-28 21:16:29 +00:00
|
|
|
:projects_list => params[:projects_list])
|
2012-07-09 17:13:02 +01:00
|
|
|
mass_build.user = current_user
|
2012-07-03 15:34:07 +01:00
|
|
|
authorize! :create, mass_build
|
|
|
|
|
|
|
|
if mass_build.save
|
|
|
|
redirect_to(platform_mass_builds_path(@platform), :notice => t("flash.platform.build_all_success"))
|
|
|
|
else
|
|
|
|
@auto_publish_selected = params[:auto_publish].present?
|
|
|
|
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
|
|
|
flash[:warning] = mass_build.errors.full_messages.join('. ')
|
|
|
|
flash[:error] = t("flash.platform.build_all_error")
|
2012-07-04 12:22:26 +01:00
|
|
|
render :index
|
2012-07-03 15:34:07 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-03-21 14:41:45 +00:00
|
|
|
def publish
|
|
|
|
if params[:status] == 'test_failed'
|
|
|
|
@mass_build.publish_test_faild_builds
|
|
|
|
else
|
|
|
|
@mass_build.publish_success_builds
|
|
|
|
end
|
|
|
|
redirect_to(platform_mass_builds_path(@mass_build.platform), :notice => t("flash.platform.publish_success"))
|
|
|
|
end
|
|
|
|
|
2012-07-03 15:34:07 +01:00
|
|
|
def index
|
2013-03-07 10:05:53 +00:00
|
|
|
authorize! :local_admin_manage, @platform
|
2012-07-03 15:34:07 +01:00
|
|
|
|
|
|
|
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
|
|
|
@auto_publish_selected = true
|
|
|
|
end
|
|
|
|
|
|
|
|
def cancel
|
2012-07-02 15:50:47 +01:00
|
|
|
@mass_build.cancel_all
|
|
|
|
flash[:notice] = t("flash.platform.cancel_mass_build")
|
2012-07-03 15:34:07 +01:00
|
|
|
redirect_to platform_mass_builds_path(@mass_build.platform)
|
2012-07-02 15:50:47 +01:00
|
|
|
end
|
|
|
|
|
2012-12-06 17:59:17 +00:00
|
|
|
def get_list
|
|
|
|
text = if params[:kind] == 'failed_builds_list'
|
|
|
|
@mass_build.generate_failed_builds_list
|
|
|
|
elsif ['projects_list', 'missed_projects_list'].include? params[:kind]
|
|
|
|
@mass_build.send params[:kind]
|
|
|
|
end
|
|
|
|
render :text => text
|
2012-07-02 15:50:47 +01:00
|
|
|
end
|
|
|
|
end
|