diff --git a/app/controllers/platforms/platforms_controller.rb b/app/controllers/platforms/platforms_controller.rb index d65a0e3d2..2299ff604 100644 --- a/app/controllers/platforms/platforms_controller.rb +++ b/app/controllers/platforms/platforms_controller.rb @@ -7,19 +7,20 @@ class Platforms::PlatformsController < Platforms::BaseController autocomplete :user, :uname def build_all - @build_lists = BuildList.for_platform(@platform) - @build_lists = @build_lists.by_mass_build(params[:mass_build_id]) unless params[:mass_build_id].blank? + mass_build = MassBuild.create!(:platform => @platform, :user => current_user) + mass_build.delay.build_all( + #mass_build.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_lists_path, :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 diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e8bb5b117..3474973bf 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -8,8 +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 == 'build_all' + # nil when controller_name == 'platforms' && action_name == 'show' 'right bigpadding' when controller_name == 'platforms' && action_name == 'clone' diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index fb3b8762f..9c6f5751b 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -1,19 +1,24 @@ class MassBuild < ActiveRecord::Base belongs_to :platform - has_many :build_lists + 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] + 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 diff --git a/app/models/platform.rb b/app/models/platform.rb index 2face5a28..a0629bdd4 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -161,7 +161,7 @@ class Platform < ActiveRecord::Base # Set options to build all need repositories = opts[:repositories] ? self.repositories.where(:id => opts[:repositories]) : self.repositories arches = opts[:arches] ? Arch.where(:id => opts[:arches]) : Arch.all - auto_publish = opts[:auto_publish] || true + auto_publish = opts[:auto_publish] || false user = opts[:user] mass_build_id = opts[:mass_build_id] @@ -174,6 +174,7 @@ class Platform < ActiveRecord::Base p.build_for(self, user, arch, auto_publish, mass_build_id) rescue RuntimeError, Exception p.delay.build_for(self, user, arch, auto_publish, mass_build_id) + #p.build_for(self, user, arch, auto_publish, mass_build_id) end end end diff --git a/app/models/project.rb b/app/models/project.rb index f40717e41..bbcb54679 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -86,7 +86,7 @@ class Project < ActiveRecord::Base bl.project_version = "latest_#{platform.name}" bl.build_requires = false # already set as db default bl.user = user - bl.auto_publish = true # already set as db default + bl.auto_publish = auto_publish # already set as db default bl.include_repos = build_ids bl.priority = priority bl.mass_build_id = mass_build_id diff --git a/app/views/platforms/platforms/build_all.html.haml b/app/views/platforms/platforms/build_all.html.haml index b4527644f..a35fe5f06 100644 --- a/app/views/platforms/platforms/build_all.html.haml +++ b/app/views/platforms/platforms/build_all.html.haml @@ -1,20 +1,60 @@ -= form_for :build, :url => build_all_platform_path(@platform), :html => { :class => 'form mass_build', :method => :post } do |f| - %section.left - %h3= t("activerecord.attributes.build_list.build_for_platform") - - @platform.repositories.each do |rep| - = check_box_tag "repositories[]", rep.id, (params[:repositories]||[]).include?(rep.id.to_s), :id => "repositories_#{rep.id}" - = label_tag "repositories_#{rep.id}", rep.name +- content_for(:sidebar) do + = form_for :build, :url => build_all_platform_path(@platform), :html => { :class => 'form mass_build', :method => :post } do |f| + .bordered.nopadding + .table + %h3= t("activerecord.attributes.build_list.build_for_platform") + - @platform.repositories.each do |rep| + .lefter + = 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 + .table + %h3= t("activerecord.attributes.build_list.arch") + - Arch.recent.each do |arch| + .lefter + = 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 + .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 t('activerecord.attributes.mass_build.auto_publish') + .both .both - %section.right - %h3= t("activerecord.attributes.build_list.arch") - - Arch.recent.each do |arch| - .lefter - = 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 - %h3= t("activerecord.attributes.build_list.preferences") - .both - = check_box_tag :auto_publish, true, params[:auto_publish].present? ? params[:auto_publish].present? : true, :id => 'auto_publish' - = label_tag :auto_publish - %br - = f.submit t("layout.projects.build_button") + %br + = f.submit t("layout.projects.build_button") + + %br + %br + .bordered.nopadding + .table + - ['BuildList::BUILD_PUBLISHED', 'BuildServer::SUCCESS', 'BuildServer::BUILD_STARTED', 'BuildList::BUILD_PENDING', 'BuildServer::BUILD_ERROR'].each do |state| + .lefter + = t("layout.build_lists.statuses.#{state.demodulize.downcase}") + .righter + = BuildList.for_status(state.constantize).for_user(current_user).for_platform(@platform).count + .both + %br + = link_to t("layout.activity_feed.all_my_builds"), build_lists_path + +%h3.fix= t("layout.platforms.mass_build") + +%table.tablesorter.unbordered + %thead + %tr + %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 diff --git a/config/locales/models/mass_build.en.yml b/config/locales/models/mass_build.en.yml new file mode 100644 index 000000000..6d016ea58 --- /dev/null +++ b/config/locales/models/mass_build.en.yml @@ -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 diff --git a/config/locales/models/mass_build.ru.yml b/config/locales/models/mass_build.ru.yml new file mode 100644 index 000000000..79eb33015 --- /dev/null +++ b/config/locales/models/mass_build.ru.yml @@ -0,0 +1,12 @@ +ru: + activerecord: + models: + mass_build: Массовая Сборка + attributes: + mass_build: + name: Название + created_at: Создан + updated_at: Обновлен + arch_names: Архитектуры + user: Пользователь + auto_publish: Авто Публикация diff --git a/config/routes.rb b/config/routes.rb index 797d0d219..74129a0fb 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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 diff --git a/db/migrate/20120523113925_add_arch_names_to_mass_builds.rb b/db/migrate/20120523113925_add_arch_names_to_mass_builds.rb new file mode 100644 index 000000000..6a6df9c69 --- /dev/null +++ b/db/migrate/20120523113925_add_arch_names_to_mass_builds.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 7ee386593..dc260d5e9 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -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| @@ -230,7 +233,7 @@ ActiveRecord::Schema.define(:version => 20120518105225) do t.string "owner_type" t.string "visibility", :default => "open", :null => false t.string "platform_type", :default => "main", :null => false - t.string "distrib_type", :null => false + t.string "distrib_type" end add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false