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]
|
|
|
|
skip_load_and_authorize_resource :platform, :only => [:cancel, :failed_builds_list]
|
|
|
|
skip_authorize_resource :platform, :only => [:create, :index]
|
|
|
|
|
|
|
|
def create
|
|
|
|
mass_build = MassBuild.new(
|
2012-07-09 14:16:52 +01:00
|
|
|
:platform_id => @platform.id,
|
|
|
|
:user_id => current_user.id,
|
2012-07-03 15:34:07 +01:00
|
|
|
:repositories => params[:repositories],
|
|
|
|
:arches => params[:arches],
|
|
|
|
:auto_publish => params[:auto_publish] || false
|
|
|
|
)
|
|
|
|
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
|
|
|
|
|
|
|
|
def index
|
|
|
|
authorize! :edit, @platform
|
|
|
|
|
|
|
|
@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
|
|
|
|
|
|
|
|
def failed_builds_list
|
|
|
|
render :text => @mass_build.generate_failed_builds_list
|
|
|
|
end
|
|
|
|
end
|