rosa-build/app/controllers/platforms/mass_builds_controller.rb

61 lines
2.1 KiB
Ruby
Raw Normal View History

#class MassBuildsController < ApplicationController
class Platforms::MassBuildsController < Platforms::BaseController
before_filter :authenticate_user!
load_and_authorize_resource :platform
load_and_authorize_resource
skip_load_and_authorize_resource :only => [:index, :create]
skip_load_and_authorize_resource :platform, :only => [:cancel, :failed_builds_list, :publish]
skip_authorize_resource :platform, :only => [:index, :create]
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,
:projects_list => params[:projects_list])
mass_build.user = current_user
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")
render :index
end
end
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
def index
authorize! :local_admin_manage, @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
@mass_build.cancel_all
flash[:notice] = t("flash.platform.cancel_mass_build")
redirect_to platform_mass_builds_path(@mass_build.platform)
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
end
end