Merge pull request #496 from warpc/442-mass_build

[refs #442] Add mass build select to monitoring. Remove build lists from build_all action
This commit is contained in:
Vladimir Sharshov 2012-05-24 02:31:56 -07:00
commit 459d5257a8
20 changed files with 94 additions and 47 deletions

View File

@ -7,19 +7,19 @@ class Platforms::PlatformsController < Platforms::BaseController
autocomplete :user, :uname
def build_all
@build_lists = BuildList.for_platform(@platform)
@build_lists = @build_lists.by_mass_build(MassBuild.find(params[:mass_build_id])) unless params[:mass_build_id].blank?
mass_build = MassBuild.create!(:platform => @platform, :user => current_user)
mass_build.delay.build_all(
:user => current_user,
:repositories => params[:repositories],
:arches => params[:arches],
:auto_publish => params[:auto_publish]
)
redirect_to(mass_builds_platform_path(@platform), :notice => t("flash.platform.build_all_success"))
end
if request.post?
mass_build = MassBuild.create(:platform => @platform)
mass_build.delay.build_all(
:user => current_user,
:repositories => params[:repositories],
:arches => params[:arches],
:auto_publish => params[:auto_publish]
)
redirect_to(build_all_platform_path(@platform), :notice => t("flash.platform.build_all_success"))
end
def mass_builds
@mass_builds = MassBuild.paginate(:page => params[:page], :per_page => 20)
render :action => :build_all
end
def index

View File

@ -8,6 +8,8 @@ module ApplicationHelper
'right slim'
when controller_name == 'build_lists' && ['new', 'create'].include?(action_name)
nil
#when controller_name == 'platforms' && action_name == 'build_all'
# nil
when controller_name == 'platforms' && action_name == 'show'
'right bigpadding'
when controller_name == 'platforms' && action_name == 'clone'

View File

@ -81,7 +81,7 @@ class Ability
can [:read, :related, :members], Platform, :owner_type => 'Group', :owner_id => user.group_ids
can([:read, :related, :members], Platform, read_relations_for('platforms')) {|platform| local_reader? platform}
can([:update, :members], Platform) {|platform| local_admin? platform}
can([:destroy, :members, :add_member, :remove_member, :remove_members, :build_all] , Platform) {|platform| owner? platform}
can([:destroy, :members, :add_member, :remove_member, :remove_members, :build_all, :mass_builds] , Platform) {|platform| owner? platform}
can :autocomplete_user_uname, Platform
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
@ -123,7 +123,7 @@ class Ability
cannot [:members, :add_member, :remove_member, :remove_members], Platform, :platform_type => 'personal'
cannot [:create, :update, :destroy, :clone], Product, :platform => {:platform_type => 'personal'}
cannot [:clone, :build_all], Platform, :platform_type => 'personal'
cannot [:clone, :build_all, :mass_builds], Platform, :platform_type => 'personal'
can :create, Subscribe do |subscribe|
!subscribe.subscribeable.subscribes.exists?(:user_id => user.id)

View File

@ -74,7 +74,7 @@ class BuildList < ActiveRecord::Base
scope :for_status, lambda {|status| where(:status => status) }
scope :for_user, lambda { |user| where(:user_id => user.id) }
scope :for_platform, lambda { |platform| where(:build_for_platform_id => platform.id) }
scope :by_mass_build, lambda { |mass_build| where(:mass_build_id => mass_build.id) }
scope :by_mass_build, lambda { |mass_build| where(:mass_build_id => mass_build) }
scope :scoped_to_arch, lambda {|arch| where(:arch_id => arch) }
scope :scoped_to_project_version, lambda {|project_version| where(:project_version => project_version) }
scope :scoped_to_is_circle, lambda {|is_circle| where(:is_circle => is_circle) }

View File

@ -18,6 +18,7 @@ class BuildList::Filter
build_lists = build_lists.scoped_to_project_version(@options[:project_version]) if @options[:project_version]
build_lists = build_lists.scoped_to_is_circle(@options[:is_circle]) if @options[:is_circle].present?
build_lists = build_lists.scoped_to_project_name(@options[:project_name]) if @options[:project_name]
build_lists = build_lists.by_mass_build(@options[:mass_build_id]) if @options[:mass_build_id]
if @options[:created_at_start] || @options[:created_at_end]
build_lists = build_lists.for_creation_date_period(@options[:created_at_start], @options[:created_at_end])
@ -53,7 +54,8 @@ class BuildList::Filter
:is_circle => nil,
:project_version => nil,
:bs_id => nil,
:project_name => nil
:project_name => nil,
:mass_build_id => nil
}))
@options[:ownership] = @options[:ownership].presence || (@project || !@user ? 'index' : 'owned')
@ -67,6 +69,7 @@ class BuildList::Filter
@options[:is_circle] = @options[:is_circle].present? ? @options[:is_circle] == "1" : nil
@options[:bs_id] = @options[:bs_id].presence
@options[:project_name] = @options[:project_name].presence
@options[:mass_build_id] = @options[:mass_build_id].presence
end
def build_date_from_params(field_name, params)

View File

@ -1,19 +1,24 @@
class MassBuild < ActiveRecord::Base
belongs_to :platform
belongs_to :user
has_many :build_lists, :dependent => :destroy
scope :by_platform, lambda { |platform| where(:platform_id => platform.id) }
def build_all(opts={})
set_name opts[:repositories]
opts.merge!({:mass_build_id => self.id})
platform.build_all opts
auto_publish = opts[:auto_publish] || false
set_data opts[:repositories], opts[:arches], auto_publish
platform.build_all opts.merge({:mass_build_id => self.id})
end
private
def set_name(repositories_ids)
def set_data(repositories_ids, arches, auto_publish=false)
rep_names = Repository.where(:id => repositories_ids).map(&:name).join(", ")
self.name = "#{Date.today.strftime("%d.%b")}-#{platform.name}(#{rep_names})"
self.save!
self.arch_names = Arch.where(:id => arches).map(&:name).join(", ")
self.auto_publish = auto_publish
self.save
end
end

View File

@ -10,6 +10,8 @@
= link_to t("layout.platforms.about"), platform_path(@platform)
%li{:class => (contr == :repositories) ? 'active' : ''}
= link_to t("layout.repositories.list_header"), platform_repositories_path(@platform)
- if can? :mass_builds, @platform
%li= link_to t("layout.platforms.mass_build"), mass_builds_platform_path(@platform)
- if can? :read, @platform.products.build
%li{:class => (contr == :products) ? 'active' : ''}
= link_to t("layout.products.list_header"), platform_products_path(@platform)

View File

@ -8,7 +8,7 @@
= check_box_tag "repositories[]", rep.id, (params[:repositories]||[]).include?(rep.id.to_s), :id => "repositories_#{rep.id}"
= label_tag "repositories_#{rep.id}", rep.name
.both
.both
.both
.table
%h3= t("activerecord.attributes.build_list.arch")
- Arch.recent.each do |arch|
@ -16,12 +16,12 @@
= check_box_tag "arches[]", arch.id, (params[:arches]||[]).include?(arch.id.to_s), :id => "arches_#{arch.id}"
= label_tag "arches_#{arch.id}", arch.name
.both
.both
.both
.table
%h3= t("activerecord.attributes.build_list.preferences")
.lefter
= check_box_tag :auto_publish, true, params[:auto_publish].present? ? params[:auto_publish].present? : true, :id => 'auto_publish'
= label_tag :auto_publish
= label_tag t('activerecord.attributes.mass_build.auto_publish')
.both
.both
%br
@ -42,22 +42,19 @@
%h3.fix= t("layout.platforms.mass_build")
- if MassBuild.exists? :platform_id => @platform.id
%br
= form_for :build, :url => build_all_platform_path(@platform), :html => { :class => :form, :method => :get } do |f|
= select_tag "mass_build_id", options_from_collection_for_select( MassBuild.by_platform(@platform), :id, :name ), :include_blank => true
= f.submit t("layout.platforms.refresh_button")
%table.tablesorter.unbordered
%thead
%tr
%th.lpadding16= t('layout.platforms.mass_build')
%th.lpadding16= t('layout.platforms.project')
%th.lpadding16= t('layout.platforms.arch')
%th.lpadding16= t('layout.platforms.build_task')
- @build_lists.each do |build_list|
%tr{:class => "#{build_list_status_color(build_list.status)}"}
%td= build_list.mass_build_id ? build_list.mass_build.name : ""
%td= link_to build_list.project.name, project_path(build_list.project)
%td= build_list.arch.name
%td= link_to (build_list.bs_id.present? ? build_list.bs_id : t("layout.build_lists.bs_id_not_set")), build_list
%th.lpadding16= t('activerecord.attributes.mass_build.name')
%th.lpadding16= t('activerecord.attributes.mass_build.arch_names')
%th.lpadding16= t('activerecord.attributes.mass_build.user')
%th.lpadding16= t('activerecord.attributes.mass_build.auto_publish')
%th.lpadding16= t('activerecord.attributes.mass_build.created_at')
- @mass_builds.each do |mass_build|
%tr
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id})
%td= mass_build.arch_names
%td= mass_build.user.name
%td= mass_build.auto_publish
%td= mass_build.created_at
= will_paginate @mass_builds

View File

@ -30,8 +30,6 @@
%td= @platform.distrib_type
.buttons_block
- if can? :build_all, @platform
= link_to t("layout.platforms.build_all"), build_all_platform_path(@platform), :confirm => I18n.t("layout.confirm"), :method => :post, :class => "button left_floated"
= link_to I18n.t("layout.platforms.clone"), clone_platform_path(@platform), :class => "button left_floated" if can? :clone, @platform
= render 'connection_info' if @platform.platform_type == 'personal' and @platform.visibility == 'open'

View File

@ -1,5 +1,6 @@
%tr{:id => "row#{build_list_counter}", :class => "#{build_list_status_color(build_list.status)}"}
%td= link_to (build_list.bs_id.present? ? build_list.bs_id : t("layout.build_lists.bs_id_not_set")), build_list
%td= build_list.mass_build_id ? build_list.mass_build.name : ""
%td= build_list.human_status
%td= link_to build_list.project.name, build_list.project
%td= link_to build_list.project_version, "#"

View File

@ -37,6 +37,8 @@
%br
= f.submit t("layout.search.header")
.block
%h3.small= t("activerecord.attributes.build_list.mass_build")
.lineForm.aside= f.select :mass_build_id, options_from_collection_for_select( MassBuild.all, :id, :name, @filter.mass_build_id ), {:include_blank => true}
%h3.small= t("activerecord.attributes.build_list.status")
.lineForm.aside= f.select :status, BuildList::STATUSES.collect{|status| [BuildList.human_status(status), status]}, {:include_blank => true, :selected => @filter.status}, {:class => 'sel80 aside', :id => 'status', :tabindex => 2}
%h3.small= t("activerecord.attributes.build_list.is_circle")

View File

@ -4,6 +4,7 @@
%thead
%tr
%th.lpadding16= t("activerecord.attributes.build_list.bs_id")
%th.lpadding16= t('activerecord.attributes.build_list.mass_build_id')
%th.lpadding16= t("activerecord.attributes.build_list.status")
%th.lpadding16= t("activerecord.attributes.build_list.project")
%th.lpadding16= t("activerecord.attributes.build_list.project_version")

View File

@ -28,6 +28,7 @@ en:
preferences: Preferences
started_at: Build started at
duration: Build duration in seconds
mass_build_id: Mass build
build_list/item:
name: Name

View File

@ -27,6 +27,7 @@ ru:
user: Пользователь
preferences: Настройки
duration: Длительность билда в секундах
mass_build_id: Массовая сборка
build_list/item:
name: Название

View File

@ -0,0 +1,12 @@
en:
activerecord:
models:
mass_build: Mass Build
attributes:
mass_build:
name: Name
created_at: Created
updated_at: Updated
arch_names: Architectures
user: User
auto_publish: Auto Publish

View File

@ -0,0 +1,12 @@
ru:
activerecord:
models:
mass_build: Массовая Сборка
attributes:
mass_build:
name: Название
created_at: Создан
updated_at: Обновлен
arch_names: Архитектуры
user: Пользователь
auto_publish: Авто Публикация

View File

@ -42,7 +42,7 @@ en:
members: Members
project: Project
arch: Architecture
mass_build: Mass Build
mass_build: Mass build
build_task: Build Task
refresh_button: Refresh

View File

@ -48,7 +48,7 @@ Rosa::Application.routes.draw do
post :add_member
post :make_clone
post :build_all
get :build_all
get :mass_builds
end
get :autocomplete_user_uname, :on => :collection
resources :repositories do

View File

@ -0,0 +1,7 @@
class AddArchNamesToMassBuilds < ActiveRecord::Migration
def change
add_column :mass_builds, :arch_names, :string
add_column :mass_builds, :user_id, :integer
add_column :mass_builds, :auto_publish, :boolean
end
end

View File

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120518105225) do
ActiveRecord::Schema.define(:version => 20120523113925) do
create_table "activity_feeds", :force => true do |t|
t.integer "user_id", :null => false
@ -215,8 +215,11 @@ ActiveRecord::Schema.define(:version => 20120518105225) do
create_table "mass_builds", :force => true do |t|
t.integer "platform_id"
t.string "name"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "arch_names"
t.integer "user_id"
t.boolean "auto_publish"
end
create_table "platforms", :force => true do |t|