[issue #428] Merge branch 'master' into 428-advisory
Conflicts: db/schema.rb
This commit is contained in:
commit
a909a92ae8
|
@ -0,0 +1,49 @@
|
|||
#class MassBuildsController < ApplicationController
|
||||
class Platforms::MassBuildsController < Platforms::BaseController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
load_and_authorize_resource :platform
|
||||
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]
|
||||
|
||||
def create
|
||||
mass_build = MassBuild.new(
|
||||
:platform => @platform,
|
||||
:user => current_user,
|
||||
:repositories => params[:repositories],
|
||||
:arches => params[:arches],
|
||||
:auto_publish => params[:auto_publish] || false
|
||||
)
|
||||
authorize! :create, mass_build
|
||||
|
||||
if mass_build.save
|
||||
redirect_to(platform_mass_builds_path(@platform), :notice => t("flash.platform.build_all_success"))
|
||||
else
|
||||
@auto_publish_selected = params[:auto_publish].present?
|
||||
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
||||
flash[:warning] = mass_build.errors.full_messages.join('. ')
|
||||
flash[:error] = t("flash.platform.build_all_error")
|
||||
render :index
|
||||
end
|
||||
end
|
||||
|
||||
def index
|
||||
authorize! :edit, @platform
|
||||
|
||||
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
||||
@auto_publish_selected = true
|
||||
end
|
||||
|
||||
def cancel
|
||||
@mass_build.cancel_all
|
||||
flash[:notice] = t("flash.platform.cancel_mass_build")
|
||||
redirect_to platform_mass_builds_path(@mass_build.platform)
|
||||
end
|
||||
|
||||
def failed_builds_list
|
||||
render :text => @mass_build.generate_failed_builds_list
|
||||
end
|
||||
end
|
|
@ -7,35 +7,6 @@ class Platforms::PlatformsController < Platforms::BaseController
|
|||
|
||||
autocomplete :user, :uname
|
||||
|
||||
def build_all
|
||||
mass_build = MassBuild.new(
|
||||
:platform => @platform,
|
||||
:user => current_user,
|
||||
:repositories => params[:repositories],
|
||||
:arches => params[:arches],
|
||||
:auto_publish => params[:auto_publish] || false
|
||||
)
|
||||
if mass_build.save
|
||||
redirect_to(mass_builds_platform_path(@platform), :notice => t("flash.platform.build_all_success"))
|
||||
else
|
||||
@auto_publish_selected = params[:auto_publish].present?
|
||||
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
||||
flash[:warning] = mass_build.errors.full_messages.join('. ')
|
||||
flash[:error] = t("flash.platform.build_all_error")
|
||||
end
|
||||
end
|
||||
|
||||
def mass_builds
|
||||
@mass_builds = MassBuild.by_platform(@platform).order('created_at DESC').paginate(:page => params[:page], :per_page => 20)
|
||||
@auto_publish_selected = true
|
||||
render :action => :build_all
|
||||
end
|
||||
|
||||
def failed_builds_list
|
||||
@mass_build = MassBuild.find params[:mass_build_id]
|
||||
render :text => @mass_build.generate_failed_builds_list
|
||||
end
|
||||
|
||||
def index
|
||||
@platforms = @platforms.accessible_by(current_ability, :related).paginate(:page => params[:page], :per_page => 20)
|
||||
end
|
||||
|
|
|
@ -83,7 +83,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, :mass_builds] , Platform) {|platform| owner? platform}
|
||||
can([:destroy, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) }
|
||||
can [:autocomplete_user_uname, :read_advisories, :advisories], Platform
|
||||
|
||||
can [:read, :projects_list], Repository, :platform => {:visibility => 'open'}
|
||||
|
@ -127,7 +127,9 @@ 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, :mass_builds], Platform, :platform_type => 'personal'
|
||||
cannot [:clone], Platform, :platform_type => 'personal'
|
||||
can([:failed_builds_list, :create], MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && (mass_build.platform.platform_type == 'main') }
|
||||
can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build && (mass_build.platform.platform_type == 'main')}
|
||||
|
||||
can :create, Subscribe do |subscribe|
|
||||
!subscribe.subscribeable.subscribes.exists?(:user_id => user.id)
|
||||
|
|
|
@ -219,6 +219,10 @@ class BuildList < ActiveRecord::Base
|
|||
self.class.human_status(status)
|
||||
end
|
||||
|
||||
def self.status_by_human(human)
|
||||
BuildList::HUMAN_STATUSES.key human
|
||||
end
|
||||
|
||||
def set_items(items_hash)
|
||||
self.items = []
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ class MassBuild < ActiveRecord::Base
|
|||
|
||||
attr_accessor :repositories, :arches
|
||||
|
||||
validates :platform_id, :arch_names, :name, :user_id, :repositories, :presence => true
|
||||
validates :platform_id, :arch_names, :name, :user_id, :repositories, :rep_names, :presence => true
|
||||
validates_inclusion_of :auto_publish, :in => [true, false]
|
||||
|
||||
after_create :build_all
|
||||
|
@ -25,8 +25,8 @@ class MassBuild < ActiveRecord::Base
|
|||
super
|
||||
|
||||
if new_record?
|
||||
rep_names = Repository.where(:id => self.repositories).map(&:name).join(", ")
|
||||
self.name = "#{Time.now.utc.to_date.strftime("%d.%b")}-#{platform.name}(#{rep_names})"
|
||||
self.rep_names = Repository.where(:id => self.repositories).map(&:name).join(", ")
|
||||
self.name = "#{Time.now.utc.to_date.strftime("%d.%b")}-#{platform.name}"
|
||||
self.arch_names = Arch.where(:id => self.arches).map(&:name).join(", ")
|
||||
end
|
||||
end
|
||||
|
@ -50,4 +50,12 @@ class MassBuild < ActiveRecord::Base
|
|||
end
|
||||
report
|
||||
end
|
||||
|
||||
def cancel_all
|
||||
self.update_attribute(:stop_build, true)
|
||||
self.build_lists.find_each(:batch_size => 100) do |bl|
|
||||
bl.cancel
|
||||
end
|
||||
end
|
||||
later :cancel_all, :queue => :clone_build
|
||||
end
|
||||
|
|
|
@ -167,6 +167,7 @@ class Platform < ActiveRecord::Base
|
|||
auto_publish = opts[:auto_publish] || false
|
||||
user = opts[:user]
|
||||
mass_build_id = opts[:mass_build_id]
|
||||
mass_build = MassBuild.find mass_build_id
|
||||
|
||||
repositories.each do |rep|
|
||||
rep.projects.find_in_batches(:batch_size => 2) do |group|
|
||||
|
@ -174,6 +175,7 @@ class Platform < ActiveRecord::Base
|
|||
group.each do |p|
|
||||
arches.map(&:name).each do |arch|
|
||||
begin
|
||||
return if mass_build.reload.stop_build
|
||||
p.build_for(self, user, arch, auto_publish, mass_build_id)
|
||||
rescue RuntimeError, Exception
|
||||
# p.async(:build_for, self, user, arch, auto_publish, mass_build_id) # TODO need this?
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
= 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{:class => (contr == :platforms && [:mass_builds, :build_all].include?(act)) ? 'active' : ''}
|
||||
= link_to t("layout.platforms.mass_build"), mass_builds_platform_path(@platform)
|
||||
- if can? :edit, @platform
|
||||
%li{:class => (contr == :mass_builds && [:index, :create].include?(act)) ? 'active' : ''}
|
||||
= link_to t("layout.platforms.mass_build"), platform_mass_builds_path(@platform)
|
||||
- if can? :read, @platform.products.build
|
||||
%li{:class => (contr == :products) ? 'active' : ''}
|
||||
= link_to t("layout.products.list_header"), platform_products_path(@platform)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
= render 'submenu'
|
||||
= render 'sidebar'
|
||||
= render 'platforms/base/submenu'
|
||||
= render 'platforms/base/sidebar'
|
||||
|
||||
= form_for :build, :url => build_all_platform_path(@platform), :html => { :class => 'form mass_build', :method => :post } do |f|
|
||||
= form_for :build, :url => platform_mass_builds_path(@platform), :html => { :class => 'form mass_build', :method => :post } do |f|
|
||||
%section.left
|
||||
%h3= t("layout.mass_builds.repositories")
|
||||
- @platform.repositories.each do |rep|
|
||||
|
@ -32,6 +32,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.extended_data")
|
||||
- @mass_builds.each do |mass_build|
|
||||
%tr
|
||||
|
@ -39,16 +40,20 @@
|
|||
%td= link_to mass_build.name, build_lists_path(:filter => {:mass_build_id => mass_build.id})
|
||||
%td.min_width_120
|
||||
- MassBuild::COUNT_STATUSES.each do |status|
|
||||
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:status => status, :mass_build_id => mass_build.id})
|
||||
= link_to t("layout.build_lists.statuses.#{status}") + ": ", build_lists_path(:filter => {:mass_build_id => mass_build.id, :ownership => 'index'}.merge(status != :build_lists ? {:status => BuildList.status_by_human(status)} : {}))
|
||||
= mass_build.read_attribute "#{status}_count"
|
||||
.both
|
||||
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platforms_path(:mass_build_id => mass_build.id), :target => "_blank"
|
||||
%td= link_to t("layout.mass_builds.failed_builds_list"), failed_builds_list_platform_mass_build_path(@platform, mass_build.id), :target => "_blank" if can?(:failed_builds_list, mass_build)
|
||||
%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
|
||||
%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 }"}
|
||||
= t('activerecord.attributes.mass_build.arch_names') + ": "
|
||||
= mass_build.arch_names
|
||||
.both
|
||||
= t('activerecord.attributes.mass_build.rep_names') + ": "
|
||||
= mass_build.rep_names
|
||||
.both
|
||||
= t('activerecord.attributes.mass_build.user') + ": "
|
||||
= link_to mass_build.user.fullname, mass_build.user
|
||||
.both
|
|
@ -6,7 +6,7 @@
|
|||
<% @projects.each do |project| %>
|
||||
[
|
||||
"<%=j link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project) %>",
|
||||
"<%= truncate(project.description || '', :length => 60).gsub("\n", ' ').gsub("\r", ' ') %>",
|
||||
"<%= truncate(project.description || '', :length => 60).gsub(/\n|\r|\t/, ' ') %>",
|
||||
"<%=j link_to t("layout.add"), url_for(:controller => :repositories, :action => :add_project, :project_id => project.id) %>"
|
||||
]<%= project == @projects.last ? '' : ',' %>
|
||||
<% end %>
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
j(link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project)) +
|
||||
"</div>").html_safe
|
||||
%>",
|
||||
"<%= truncate(project.description || '', :length => 60).gsub("\n", ' ').gsub("\r", ' ') %>",
|
||||
"<%= truncate(project.description || '', :length => 60).gsub(/\n|\r|\t/, ' ') %>",
|
||||
"<%=
|
||||
if can? :remove_project, @repository
|
||||
j(link_to('<span class="delete"> </span>'.html_safe,
|
||||
|
|
|
@ -6,5 +6,5 @@
|
|||
%td= link_to build_list.project_version, "#"
|
||||
%td= build_list.arch.name
|
||||
%td= link_to build_list.user.try(:fullname), build_list.user
|
||||
%td= link_to image_tag('x.png', :class => 'delete-row', :id => "delete-row#{build_list_counter}"), cancel_build_list_path(build_list), :method => :put, :confirm => t('layout.confirm') if can?(:cancel, build_list)
|
||||
%td= link_to image_tag('x.png', :class => 'delete-row', :id => "delete-row#{build_list_counter}"), cancel_build_list_path(build_list), :method => :put, :confirm => t('layout.confirm') if build_list.can_cancel? and can?(:cancel, build_list)
|
||||
%td= build_list.updated_at
|
||||
|
|
|
@ -5,6 +5,8 @@ en:
|
|||
extended_data: Extended data
|
||||
failed_builds_list: Failed Builds List
|
||||
statuses: Statuses
|
||||
cancel_mass_build: Cancel
|
||||
cancel_confirm: Are you sure you want to cancel mass build?
|
||||
activerecord:
|
||||
models:
|
||||
mass_build: Mass Build
|
||||
|
@ -18,3 +20,4 @@ en:
|
|||
user: User
|
||||
auto_publish: Auto Publish
|
||||
repositories: Repositories
|
||||
rep_names: Repositories
|
||||
|
|
|
@ -5,6 +5,8 @@ ru:
|
|||
extended_data: Параметры задания
|
||||
failed_builds_list: Список ошибок сборок
|
||||
statuses: Статусы
|
||||
cancel_mass_build: Отмена
|
||||
cancel_confirm: Вы уверены, что хотите отменить массовую сборку?
|
||||
activerecord:
|
||||
models:
|
||||
mass_build: Массовая Сборка
|
||||
|
@ -18,3 +20,4 @@ ru:
|
|||
user: Пользователь
|
||||
auto_publish: Авто Публикация
|
||||
repositories: Репозитории
|
||||
rep_names: Репозитории
|
||||
|
|
|
@ -59,6 +59,7 @@ en:
|
|||
destroyed: Platform deleted
|
||||
build_all_success: All project build in progress
|
||||
build_all_error: Mass build failed
|
||||
cancel_mass_build: Mass build canceled
|
||||
clone_success: Cloned successfully
|
||||
members:
|
||||
already_added: "%{name} is already a member of platform"
|
||||
|
|
|
@ -59,6 +59,7 @@ ru:
|
|||
destroyed: Платформа успешно удалена
|
||||
build_all_success: Все проекты успешно отправлены на сборку
|
||||
build_all_error: Сборка не удалась!
|
||||
cancel_mass_build: Массовая сборка отменена
|
||||
clone_success: Клонирование успешно
|
||||
members:
|
||||
already_added: "%{name} уже является участником платформы"
|
||||
|
|
|
@ -53,13 +53,16 @@ Rosa::Application.routes.draw do
|
|||
delete :remove_member
|
||||
post :add_member
|
||||
post :make_clone
|
||||
post :build_all
|
||||
get :mass_builds
|
||||
get :advisories
|
||||
end
|
||||
collection do
|
||||
get :failed_builds_list
|
||||
|
||||
resources :mass_builds, :only => [:create, :index] do
|
||||
member do
|
||||
get :failed_builds_list
|
||||
post :cancel
|
||||
end
|
||||
end
|
||||
|
||||
get :autocomplete_user_uname, :on => :collection
|
||||
resources :repositories do
|
||||
member do
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddRepNamesToMassBuilds < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :mass_builds, :rep_names, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,5 @@
|
|||
class AddStopBuildToMassBuilds < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :mass_builds, :stop_build, :boolean, :null => false, :default => false
|
||||
end
|
||||
end
|
|
@ -0,0 +1,10 @@
|
|||
class AddNullFalseToMassBuildsCounters < ActiveRecord::Migration
|
||||
def change
|
||||
change_column :mass_builds, :build_lists_count, :integer, :default => 0, :null => false
|
||||
change_column :mass_builds, :build_published_count, :integer, :default => 0, :null => false
|
||||
change_column :mass_builds, :build_pending_count, :integer, :default => 0, :null => false
|
||||
change_column :mass_builds, :build_started_count, :integer, :default => 0, :null => false
|
||||
change_column :mass_builds, :build_publish_count, :integer, :default => 0, :null => false
|
||||
change_column :mass_builds, :build_error_count, :integer, :default => 0, :null => false
|
||||
end
|
||||
end
|
42
db/schema.rb
42
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20120628165702) do
|
||||
ActiveRecord::Schema.define(:version => 20120703101719) do
|
||||
|
||||
create_table "activity_feeds", :force => true do |t|
|
||||
t.integer "user_id", :null => false
|
||||
|
@ -107,8 +107,8 @@ ActiveRecord::Schema.define(:version => 20120628165702) do
|
|||
t.integer "project_id"
|
||||
t.integer "arch_id"
|
||||
t.datetime "notified_at"
|
||||
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.boolean "is_circle", :default => false
|
||||
t.text "additional_repos"
|
||||
t.string "name"
|
||||
|
@ -137,8 +137,8 @@ ActiveRecord::Schema.define(:version => 20120628165702) do
|
|||
t.string "commentable_type"
|
||||
t.integer "user_id"
|
||||
t.text "body"
|
||||
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.decimal "commentable_id", :precision => 50, :scale => 0
|
||||
t.integer "project_id"
|
||||
end
|
||||
|
@ -161,8 +161,8 @@ ActiveRecord::Schema.define(:version => 20120628165702) do
|
|||
|
||||
create_table "groups", :force => true do |t|
|
||||
t.integer "owner_id"
|
||||
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 "uname"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.text "description"
|
||||
|
@ -175,8 +175,8 @@ ActiveRecord::Schema.define(:version => 20120628165702) do
|
|||
t.string "title"
|
||||
t.text "body"
|
||||
t.string "status", :default => "open"
|
||||
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.integer "user_id"
|
||||
t.datetime "closed_at"
|
||||
t.integer "closed_by"
|
||||
|
@ -211,12 +211,14 @@ ActiveRecord::Schema.define(:version => 20120628165702) do
|
|||
t.string "arch_names"
|
||||
t.integer "user_id"
|
||||
t.boolean "auto_publish", :default => false, :null => false
|
||||
t.integer "build_lists_count", :default => 0
|
||||
t.integer "build_published_count", :default => 0
|
||||
t.integer "build_pending_count", :default => 0
|
||||
t.integer "build_started_count", :default => 0
|
||||
t.integer "build_publish_count", :default => 0
|
||||
t.integer "build_error_count", :default => 0
|
||||
t.integer "build_lists_count", :default => 0, :null => false
|
||||
t.integer "build_published_count", :default => 0, :null => false
|
||||
t.integer "build_pending_count", :default => 0, :null => false
|
||||
t.integer "build_started_count", :default => 0, :null => false
|
||||
t.integer "build_publish_count", :default => 0, :null => false
|
||||
t.integer "build_error_count", :default => 0, :null => false
|
||||
t.string "rep_names"
|
||||
t.boolean "stop_build", :default => false, :null => false
|
||||
end
|
||||
|
||||
create_table "platforms", :force => true do |t|
|
||||
|
@ -372,8 +374,9 @@ ActiveRecord::Schema.define(:version => 20120628165702) do
|
|||
|
||||
create_table "users", :force => true do |t|
|
||||
t.string "name"
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :default => "", :null => false
|
||||
t.string "email", :default => "", :null => false
|
||||
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
||||
t.string "password_salt", :default => "", :null => false
|
||||
t.string "reset_password_token"
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.datetime "remember_created_at"
|
||||
|
@ -382,11 +385,12 @@ ActiveRecord::Schema.define(:version => 20120628165702) do
|
|||
t.text "ssh_key"
|
||||
t.string "uname"
|
||||
t.string "role"
|
||||
t.string "language", :default => "en"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.string "language", :default => "en"
|
||||
t.string "confirmation_token"
|
||||
t.datetime "confirmed_at"
|
||||
t.datetime "confirmation_sent_at"
|
||||
t.integer "own_projects_count", :default => 0, :null => false
|
||||
t.datetime "reset_password_sent_at"
|
||||
t.text "professional_experience"
|
||||
t.string "site"
|
||||
t.string "company"
|
||||
|
|
Loading…
Reference in New Issue