diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 0fba4a2d9..180de2816 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -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; } diff --git a/app/controllers/platforms/mass_builds_controller.rb b/app/controllers/platforms/mass_builds_controller.rb index f35127f1d..ff90c71b2 100644 --- a/app/controllers/platforms/mass_builds_controller.rb +++ b/app/controllers/platforms/mass_builds_controller.rb @@ -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 diff --git a/app/models/ability.rb b/app/models/ability.rb index f7d26c011..7e4ff93e6 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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} diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index ffa14c480..cfcdf61ba 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -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}" diff --git a/app/views/platforms/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml index 77b52a940..cf8ffa71e 100644 --- a/app/views/platforms/mass_builds/index.html.haml +++ b/app/views/platforms/mass_builds/index.html.haml @@ -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 }"} diff --git a/config/locales/models/mass_build.en.yml b/config/locales/models/mass_build.en.yml index b8adf2f1f..bafb62b01 100644 --- a/config/locales/models/mass_build.en.yml +++ b/config/locales/models/mass_build.en.yml @@ -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: ' diff --git a/config/locales/models/mass_build.ru.yml b/config/locales/models/mass_build.ru.yml index f202ba420..974e7f09d 100644 --- a/config/locales/models/mass_build.ru.yml +++ b/config/locales/models/mass_build.ru.yml @@ -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: 'Несуществующие проекты: ' diff --git a/config/locales/models/platform.en.yml b/config/locales/models/platform.en.yml index afb83a510..b834312d1 100644 --- a/config/locales/models/platform.en.yml +++ b/config/locales/models/platform.en.yml @@ -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" diff --git a/config/locales/models/platform.ru.yml b/config/locales/models/platform.ru.yml index a379f293b..366852ada 100644 --- a/config/locales/models/platform.ru.yml +++ b/config/locales/models/platform.ru.yml @@ -62,6 +62,7 @@ ru: build_all_success: Все проекты успешно отправлены на сборку build_all_error: Сборка не удалась! cancel_mass_build: Массовая сборка отменена + publish_success: Сборки отправленны в очередь на публикацию успешно clone_success: Клонирование успешно members: successfully_added: "Участник %{name} успешно добавлен к платформе" diff --git a/config/routes.rb b/config/routes.rb index 4d5e5c11c..6d0e10947 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -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