2011-10-29 20:09:14 +01:00
|
|
|
class AutoBuildListsController < ApplicationController
|
|
|
|
before_filter :authenticate_user!, :except => :auto_build
|
2011-11-19 11:41:11 +00:00
|
|
|
before_filter :find_auto_build_list, :only => :destroy
|
|
|
|
|
2011-11-24 21:46:19 +00:00
|
|
|
load_and_authorize_resource
|
|
|
|
|
2011-10-29 20:09:14 +01:00
|
|
|
def index
|
2011-11-17 21:57:30 +00:00
|
|
|
projects = Project.where(:owner_id => current_user.id, :owner_type => 'User').order('name ASC')
|
2011-11-02 19:18:25 +00:00
|
|
|
@projects_not_automated = projects.automateable.paginate(:page => params[:not_automated_page])
|
2011-10-29 20:09:14 +01:00
|
|
|
@projects_not_automated = @projects_not_automated.where(:name => params[:name]) unless params[:name].blank?
|
2011-11-02 19:18:25 +00:00
|
|
|
|
|
|
|
@projects_already_automated = projects.select('projects.*, auto_build_lists.id auto_build_lists_id').
|
|
|
|
joins(:auto_build_lists).paginate(:page => params[:already_automated_page])
|
2011-10-29 20:09:14 +01:00
|
|
|
end
|
2011-11-24 21:46:19 +00:00
|
|
|
|
2011-10-29 20:09:14 +01:00
|
|
|
def create
|
|
|
|
@auto_build_list = AutoBuildList.new(
|
2011-11-28 15:41:42 +00:00
|
|
|
:bpl_id => Platform.find_by_name('mandriva2011').try(:id),
|
2011-10-29 20:09:14 +01:00
|
|
|
:pl_id => current_user.personal_platform.id,
|
|
|
|
:arch_id => Arch.find_by_name('i586').id,
|
2011-11-24 21:46:19 +00:00
|
|
|
:project_id => params[:project_id])
|
|
|
|
|
2011-10-29 20:09:14 +01:00
|
|
|
if @auto_build_list.save
|
2011-11-24 21:46:19 +00:00
|
|
|
redirect_to auto_build_lists_path, :notice => t('flash.auto_build_list.success')
|
2011-10-29 20:09:14 +01:00
|
|
|
else
|
|
|
|
redirect_to auto_build_lists_path, :notice => t('flash.auto_build_list.failed')
|
|
|
|
end
|
|
|
|
end
|
2011-11-02 19:18:25 +00:00
|
|
|
|
|
|
|
def destroy
|
2011-11-19 11:41:11 +00:00
|
|
|
if @auto_build_list.destroy
|
2011-11-02 19:18:25 +00:00
|
|
|
flash[:notice] = t('flash.auto_build_list.cancel')
|
|
|
|
else
|
|
|
|
flash[:notice] = t('flash.auto_build_list.cancel_failed')
|
|
|
|
end
|
|
|
|
redirect_to auto_build_lists_path
|
|
|
|
end
|
2011-11-19 11:41:11 +00:00
|
|
|
|
2011-11-24 21:46:19 +00:00
|
|
|
protected
|
2011-11-19 11:41:11 +00:00
|
|
|
|
|
|
|
def find_auto_build_list
|
|
|
|
@auto_build_list = AutoBuildList.find(params[:id])
|
|
|
|
end
|
2011-10-29 20:09:14 +01:00
|
|
|
end
|