#40: added ability to publish build lists of mass build.

This commit is contained in:
Vokhmin Alexey V 2013-03-21 18:41:45 +04:00
parent 30317e7a06
commit cff502bf48
10 changed files with 52 additions and 7 deletions

View File

@ -1537,6 +1537,10 @@ table.tablesorter.platform-maintainers.static-search thead tr.search th input[ty
width: 430px;
}
.tablesorter .right {
text-align: right;
}
.all_platforms {
> .both { margin: 0 0 5px; }
.build_for_pl { font-weight: bold; }

View File

@ -6,8 +6,8 @@ class Platforms::MassBuildsController < Platforms::BaseController
load_and_authorize_resource
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]
skip_load_and_authorize_resource :platform, :only => [:cancel, :failed_builds_list, :publish]
skip_authorize_resource :platform, :only => [:index, :create]
def create
mass_build = @platform.mass_builds.new(:arches => params[:arches],
@ -27,6 +27,15 @@ class Platforms::MassBuildsController < Platforms::BaseController
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

View File

@ -98,7 +98,7 @@ class Ability
can([:update, :destroy], Platform) {|platform| owner?(platform) }
can([:local_admin_manage, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
can([:get_list, :create], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && mass_build.platform.main?}
can([:get_list, :create, :publish], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && mass_build.platform.main?}
can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build && mass_build.platform.main?}
can [:read, :projects_list, :projects], Repository, :platform => {:owner_type => 'User', :owner_id => user.id}

View File

@ -70,8 +70,24 @@ class MassBuild < ActiveRecord::Base
end
later :cancel_all, :queue => :clone_build
def publish_success_builds
publish BuildList::SUCCESS, BuildList::FAILED_PUBLISH
end
later :publish_success_builds, :queue => :clone_build
def publish_test_faild_builds
publish BuildList::TESTS_FAILED
end
later :publish_test_faild_builds, :queue => :clone_build
private
def publish(*statuses)
build_lists.where(:status => statuses).order(:id).find_in_batches(:batch_size => 50) do |bls|
bls.each{ |bl| bl.can_publish? && bl.now_publish }
end
end
def set_data
if new_record?
self.name = "#{Time.now.utc.to_date.strftime("%d.%b")}-#{platform.name}"

View File

@ -27,7 +27,7 @@
%th.lpadding16= t('activerecord.attributes.mass_build.name')
%th.lpadding16= t("layout.mass_builds.statuses")
%th.lpadding16= t("layout.mass_builds.failed_builds_list")
%th.lpadding16= t("layout.mass_builds.cancel_mass_build")
%th.lpadding16= t("layout.mass_builds.actions")
%th.lpadding16= t("layout.mass_builds.extended_data")
- @mass_builds.each do |mass_build|
%tr
@ -43,7 +43,16 @@
= mass_build.read_attribute 'missed_projects_count'
%td
=link_to_list @platform, mass_build, 'failed_builds_list'
%td= link_to image_tag('x.png'), cancel_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel, mass_build)
%td.right
- if can?(:publish, mass_build)
- if mass_build.auto_publish?
= link_to t("layout.mass_builds.publish_success"), publish_platform_mass_build_path(@platform, mass_build.id), :method => :post
%br
= link_to t("layout.mass_builds.publish_test_failed"), publish_platform_mass_build_path(@platform, mass_build.id, :status => 'test_failed'), :method => :post
%br
- if can?(:cancel, mass_build)
= link_to image_tag('x.png'), cancel_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t('layout.mass_builds.cancel_confirm')
%td
%a.toggle_btn{:href => "#toggle_#{ mass_build.id }", :'data-target' => "#toggle_#{ mass_build.id }"}= t("layout.mass_builds.extended_data")
.toggle{:id => "toggle_#{ mass_build.id }"}

View File

@ -1,11 +1,13 @@
en:
layout:
mass_builds:
publish_success: Publish success builds
publish_test_failed: Publish test failed builds
repositories: Repositories
extended_data: Extended data
failed_builds_list: Failed Builds List
statuses: Statuses
cancel_mass_build: Cancel
actions: Actions
cancel_confirm: Are you sure you want to cancel mass build?
projects_list: Projects list
missed_projects_list: 'Missed projects: '

View File

@ -1,11 +1,13 @@
ru:
layout:
mass_builds:
publish_success: Опубликовать успешные сборки
publish_test_failed: Опубликовать сборки с проваленными тестами
repositories: Репозитории
extended_data: Параметры задания
failed_builds_list: Список ошибок сборок
statuses: Статусы
cancel_mass_build: Отмена
actions: Действия
cancel_confirm: Вы уверены, что хотите отменить массовую сборку?
projects_list: Список проектов
missed_projects_list: 'Несуществующие проекты: '

View File

@ -62,6 +62,7 @@ en:
build_all_success: All project build in progress
build_all_error: Mass build failed
cancel_mass_build: Mass build canceled
publish_success: Builds have been sent to queue for publishing successfully
clone_success: Cloned successfully
members:
successfully_added: "%{name} successfully added to the platform"

View File

@ -62,6 +62,7 @@ ru:
build_all_success: Все проекты успешно отправлены на сборку
build_all_error: Сборка не удалась!
cancel_mass_build: Массовая сборка отменена
publish_success: Сборки отправленны в очередь на публикацию успешно
clone_success: Клонирование успешно
members:
successfully_added: "Участник %{name} успешно добавлен к платформе"

View File

@ -145,6 +145,7 @@ Rosa::Application.routes.draw do
resources :mass_builds, :only => [:create, :index] do
member do
post :cancel
post :publish
get '/:kind.:format' => "mass_builds#get_list", :as => :get_list, :kind => /failed_builds_list|missed_projects_list|projects_list/
end
end