From ce163f89a939553cce5f18fe5d02c44e458eccf5 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Thu, 28 Jun 2012 19:23:33 +0400 Subject: [PATCH 01/14] [refs #442] Add rep_name field. Add cancel builds ability --- app/controllers/platforms/platforms_controller.rb | 7 +++++++ app/models/mass_build.rb | 12 +++++++++--- app/views/platforms/platforms/build_all.html.haml | 5 +++++ config/locales/models/mass_build.en.yml | 3 +++ config/locales/models/mass_build.ru.yml | 3 +++ config/locales/models/platform.en.yml | 1 + config/locales/models/platform.ru.yml | 1 + config/routes.rb | 1 + .../20120622092725_add_counters_to_mass_builds.rb | 12 ++++++------ .../20120628142723_add_rep_names_to_mass_builds.rb | 5 +++++ db/schema.rb | 3 ++- 11 files changed, 43 insertions(+), 10 deletions(-) create mode 100644 db/migrate/20120628142723_add_rep_names_to_mass_builds.rb diff --git a/app/controllers/platforms/platforms_controller.rb b/app/controllers/platforms/platforms_controller.rb index 14058ba36..5f77f09f2 100644 --- a/app/controllers/platforms/platforms_controller.rb +++ b/app/controllers/platforms/platforms_controller.rb @@ -31,6 +31,13 @@ class Platforms::PlatformsController < Platforms::BaseController render :action => :build_all end + def cancel_mass_build + @mass_build = MassBuild.find params[:mass_build_id] + @mass_build.cancel_all + flash[:notice] = t("flash.platform.cancel_mass_build") + redirect_to mass_builds_platform_path(@mass_build.platform) + end + def failed_builds_list @mass_build = MassBuild.find params[:mass_build_id] render :text => @mass_build.generate_failed_builds_list diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index 3c13d754a..eac383a10 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -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,10 @@ class MassBuild < ActiveRecord::Base end report end + + def cancel_all + self.build_lists.find_each do |bl| + bl.cancel + end + end end diff --git a/app/views/platforms/platforms/build_all.html.haml b/app/views/platforms/platforms/build_all.html.haml index 67b275ac9..412613607 100644 --- a/app/views/platforms/platforms/build_all.html.haml +++ b/app/views/platforms/platforms/build_all.html.haml @@ -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 @@ -43,12 +44,16 @@ = 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.cancel_mass_build"), cancel_mass_build_platforms_path(:mass_build_id => 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 }"} = 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 diff --git a/config/locales/models/mass_build.en.yml b/config/locales/models/mass_build.en.yml index 508bc8507..39419e928 100644 --- a/config/locales/models/mass_build.en.yml +++ b/config/locales/models/mass_build.en.yml @@ -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 all builds? activerecord: models: mass_build: Mass Build @@ -18,3 +20,4 @@ en: user: User auto_publish: Auto Publish repositories: Repositories + rep_names: Repository names diff --git a/config/locales/models/mass_build.ru.yml b/config/locales/models/mass_build.ru.yml index b5d0fee6f..e4144b94e 100644 --- a/config/locales/models/mass_build.ru.yml +++ b/config/locales/models/mass_build.ru.yml @@ -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: Названия репозиториев diff --git a/config/locales/models/platform.en.yml b/config/locales/models/platform.en.yml index af51cd808..cf44b6550 100644 --- a/config/locales/models/platform.en.yml +++ b/config/locales/models/platform.en.yml @@ -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" diff --git a/config/locales/models/platform.ru.yml b/config/locales/models/platform.ru.yml index 387b2c0f9..6c04bbca8 100644 --- a/config/locales/models/platform.ru.yml +++ b/config/locales/models/platform.ru.yml @@ -59,6 +59,7 @@ ru: destroyed: Платформа успешно удалена build_all_success: Все проекты успешно отправлены на сборку build_all_error: Сборка не удалась! + cancel_mass_build: Массовая сборка отменена clone_success: Клонирование успешно members: already_added: "%{name} уже является участником платформы" diff --git a/config/routes.rb b/config/routes.rb index f6fec3ff7..2fe9dbf92 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -57,6 +57,7 @@ Rosa::Application.routes.draw do end collection do get :failed_builds_list + post :cancel_mass_build end get :autocomplete_user_uname, :on => :collection resources :repositories do diff --git a/db/migrate/20120622092725_add_counters_to_mass_builds.rb b/db/migrate/20120622092725_add_counters_to_mass_builds.rb index 5b0ed2e73..afed190ac 100644 --- a/db/migrate/20120622092725_add_counters_to_mass_builds.rb +++ b/db/migrate/20120622092725_add_counters_to_mass_builds.rb @@ -1,10 +1,10 @@ class AddCountersToMassBuilds < ActiveRecord::Migration def change - add_column :mass_builds, :build_lists_count, :integer, :default => 0 - add_column :mass_builds, :build_published_count, :integer, :default => 0 - add_column :mass_builds, :build_pending_count, :integer, :default => 0 - add_column :mass_builds, :build_started_count, :integer, :default => 0 - add_column :mass_builds, :build_publish_count, :integer, :default => 0 - add_column :mass_builds, :build_error_count, :integer, :default => 0 + add_column :mass_builds, :build_lists_count, :integer, :default => 0, :null => false + add_column :mass_builds, :build_published_count, :integer, :default => 0, :null => false + add_column :mass_builds, :build_pending_count, :integer, :default => 0, :null => false + add_column :mass_builds, :build_started_count, :integer, :default => 0, :null => false + add_column :mass_builds, :build_publish_count, :integer, :default => 0, :null => false + add_column :mass_builds, :build_error_count, :integer, :default => 0, :null => false end end diff --git a/db/migrate/20120628142723_add_rep_names_to_mass_builds.rb b/db/migrate/20120628142723_add_rep_names_to_mass_builds.rb new file mode 100644 index 000000000..12fdc158d --- /dev/null +++ b/db/migrate/20120628142723_add_rep_names_to_mass_builds.rb @@ -0,0 +1,5 @@ +class AddRepNamesToMassBuilds < ActiveRecord::Migration + def change + add_column :mass_builds, :rep_names, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 06ac06651..db00a3068 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 => 20120622092725) do +ActiveRecord::Schema.define(:version => 20120628142723) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -210,6 +210,7 @@ ActiveRecord::Schema.define(:version => 20120622092725) do t.integer "build_started_count", :default => 0 t.integer "build_publish_count", :default => 0 t.integer "build_error_count", :default => 0 + t.string "rep_names" end create_table "platforms", :force => true do |t| From 561ebb872842afdae7e591835ba974ed01855cb8 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 29 Jun 2012 19:17:25 +0400 Subject: [PATCH 02/14] [refs #442] Add stop_build field --- app/models/mass_build.rb | 4 +-- app/models/platform.rb | 2 ++ ...629134216_add_stop_build_to_mass_builds.rb | 5 ++++ db/schema.rb | 26 +++++++++---------- 4 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 db/migrate/20120629134216_add_stop_build_to_mass_builds.rb diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index eac383a10..c588c1698 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -52,8 +52,6 @@ class MassBuild < ActiveRecord::Base end def cancel_all - self.build_lists.find_each do |bl| - bl.cancel - end + self.update_attribute(:stop_build, true) end end diff --git a/app/models/platform.rb b/app/models/platform.rb index 95cc24ba2..892a093e7 100644 --- a/app/models/platform.rb +++ b/app/models/platform.rb @@ -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? diff --git a/db/migrate/20120629134216_add_stop_build_to_mass_builds.rb b/db/migrate/20120629134216_add_stop_build_to_mass_builds.rb new file mode 100644 index 000000000..1e92dbc34 --- /dev/null +++ b/db/migrate/20120629134216_add_stop_build_to_mass_builds.rb @@ -0,0 +1,5 @@ +class AddStopBuildToMassBuilds < ActiveRecord::Migration + def change + add_column :mass_builds, :stop_build, :boolean, :null => false, :default => false + end +end diff --git a/db/schema.rb b/db/schema.rb index e102143c7..f2b1060c5 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,14 +11,14 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120628165702) do +ActiveRecord::Schema.define(:version => 20120629134216) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false t.string "kind" t.text "data" - t.datetime "created_at", :null => false - t.datetime "updated_at", :null => false + t.datetime "created_at" + t.datetime "updated_at" end create_table "advisories", :force => true do |t| @@ -211,6 +211,7 @@ ActiveRecord::Schema.define(:version => 20120628165702) do t.integer "build_publish_count", :default => 0 t.integer "build_error_count", :default => 0 t.string "rep_names" + t.boolean "stop_build", :default => false, :null => false end create_table "platforms", :force => true do |t| @@ -224,7 +225,7 @@ ActiveRecord::Schema.define(:version => 20120628165702) 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 @@ -294,27 +295,25 @@ ActiveRecord::Schema.define(:version => 20120628165702) do t.text "description" t.string "ancestry" t.boolean "has_issues", :default => true + t.boolean "has_wiki", :default => false t.string "srpm_file_name" t.string "srpm_content_type" t.integer "srpm_file_size" t.datetime "srpm_updated_at" - t.boolean "has_wiki", :default => false t.string "default_branch", :default => "master" t.boolean "is_package", :default => true, :null => false t.integer "average_build_time", :default => 0, :null => false t.integer "build_count", :default => 0, :null => false end - add_index "projects", ["owner_id"], :name => "index_projects_on_name_and_owner_id_and_owner_type", :unique => true - create_table "register_requests", :force => true do |t| t.string "name" t.string "email" t.string "token" t.boolean "approved", :default => false t.boolean "rejected", :default => false - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false t.string "interest" t.text "more" end @@ -368,6 +367,7 @@ ActiveRecord::Schema.define(:version => 20120628165702) do t.string "name" 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 "remember_created_at" t.datetime "created_at" @@ -375,8 +375,11 @@ ActiveRecord::Schema.define(:version => 20120628165702) do t.string "uname" t.string "role" t.string "language", :default => "en" - t.datetime "reset_password_sent_at" + 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" @@ -388,9 +391,6 @@ ActiveRecord::Schema.define(:version => 20120628165702) do t.integer "failed_attempts", :default => 0 t.string "unlock_token" t.datetime "locked_at" - t.string "confirmation_token" - t.datetime "confirmed_at" - t.datetime "confirmation_sent_at" t.string "authentication_token" t.integer "build_priority", :default => 50 end From 9c07879dc2d8ac22f2bc23b478e3eb0bbd2cfdf2 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 29 Jun 2012 20:01:32 +0400 Subject: [PATCH 03/14] [refs #442] Add forgotten cancel --- app/models/mass_build.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index c588c1698..2a7afb094 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -53,5 +53,8 @@ class MassBuild < ActiveRecord::Base def cancel_all self.update_attribute(:stop_build, true) + self.build_lists.find_each do |bl| + bl.cancel + end end end From 160bdca0c8157690ec2c7a15ff1c1af505ba0985 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 29 Jun 2012 22:08:33 +0400 Subject: [PATCH 04/14] [refs #442] Add cancel_all to background. Add ownership and fix status links --- app/models/mass_build.rb | 1 + app/views/platforms/platforms/build_all.html.haml | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index 2a7afb094..ff3124678 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -57,4 +57,5 @@ class MassBuild < ActiveRecord::Base bl.cancel end end + later :cancel_all, :loner => true, :queue => :clone_build end diff --git a/app/views/platforms/platforms/build_all.html.haml b/app/views/platforms/platforms/build_all.html.haml index 412613607..4a055dda9 100644 --- a/app/views/platforms/platforms/build_all.html.haml +++ b/app/views/platforms/platforms/build_all.html.haml @@ -40,7 +40,7 @@ %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 => 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" From 8cfe262045bfbf89e5fd68f3fad1f2d7f25341b6 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 29 Jun 2012 22:31:40 +0400 Subject: [PATCH 05/14] [refs #442] Fix status filter --- app/models/build_list.rb | 4 ++++ app/views/platforms/platforms/build_all.html.haml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 14ccd466d..a02638635 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -219,6 +219,10 @@ class BuildList < ActiveRecord::Base self.class.human_status(status) end + def self.status_by_human(human) + BuildList::HUMAN_STATUSES.each { |k,v| return k if v == human } + end + def set_items(items_hash) self.items = [] diff --git a/app/views/platforms/platforms/build_all.html.haml b/app/views/platforms/platforms/build_all.html.haml index 4a055dda9..072151269 100644 --- a/app/views/platforms/platforms/build_all.html.haml +++ b/app/views/platforms/platforms/build_all.html.haml @@ -40,7 +40,7 @@ %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 => {:mass_build_id => mass_build.id, :ownership => 'index'}.merge(status != :build_lists ? {:status => status} : {})) + = 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" From 004f603e02909edbd5711a0a106250307f062b59 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Fri, 29 Jun 2012 23:10:18 +0400 Subject: [PATCH 06/14] [refs #442] Add new actions rights. Cancel build list btn rights fix --- app/models/ability.rb | 4 ++-- app/views/projects/build_lists/_build_list.html.haml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/models/ability.rb b/app/models/ability.rb index 893b2643d..68b5d7375 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -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, :build_all, :mass_builds, :cancel_mass_build, :failed_builds_list] , Platform) {|platform| owner? platform} can [:autocomplete_user_uname, :read_advisories, :advisories], Platform can [:read, :projects_list], Repository, :platform => {:visibility => 'open'} @@ -127,7 +127,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, :mass_builds], Platform, :platform_type => 'personal' + cannot [:clone, :build_all, :mass_builds, :cancel_mass_build, :failed_builds_list], Platform, :platform_type => 'personal' can :create, Subscribe do |subscribe| !subscribe.subscribeable.subscribes.exists?(:user_id => user.id) diff --git a/app/views/projects/build_lists/_build_list.html.haml b/app/views/projects/build_lists/_build_list.html.haml index 9eb7b1380..abb5f43b8 100644 --- a/app/views/projects/build_lists/_build_list.html.haml +++ b/app/views/projects/build_lists/_build_list.html.haml @@ -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 From 8f9a6ee2d25011952a87cedef3808967fd7ee68a Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Mon, 2 Jul 2012 18:50:47 +0400 Subject: [PATCH 07/14] [refs #442] Change cancel btn. Move some actions to mass_builds controller. Add more ability rights --- app/controllers/mass_builds_controller.rb | 15 +++++++++++++++ app/controllers/platforms/platforms_controller.rb | 12 ------------ app/models/ability.rb | 8 ++++++-- app/models/mass_build.rb | 2 +- app/views/platforms/platforms/build_all.html.haml | 4 ++-- config/routes.rb | 10 +++++++--- 6 files changed, 31 insertions(+), 20 deletions(-) create mode 100644 app/controllers/mass_builds_controller.rb diff --git a/app/controllers/mass_builds_controller.rb b/app/controllers/mass_builds_controller.rb new file mode 100644 index 000000000..441b04503 --- /dev/null +++ b/app/controllers/mass_builds_controller.rb @@ -0,0 +1,15 @@ +class MassBuildsController < ApplicationController + before_filter :authenticate_user! + + load_and_authorize_resource + + def cancel_mass_build + @mass_build.cancel_all + flash[:notice] = t("flash.platform.cancel_mass_build") + redirect_to mass_builds_platform_path(@mass_build.platform) + end + + def failed_builds_list + render :text => @mass_build.generate_failed_builds_list + end +end diff --git a/app/controllers/platforms/platforms_controller.rb b/app/controllers/platforms/platforms_controller.rb index 5f77f09f2..09dde90c3 100644 --- a/app/controllers/platforms/platforms_controller.rb +++ b/app/controllers/platforms/platforms_controller.rb @@ -31,18 +31,6 @@ class Platforms::PlatformsController < Platforms::BaseController render :action => :build_all end - def cancel_mass_build - @mass_build = MassBuild.find params[:mass_build_id] - @mass_build.cancel_all - flash[:notice] = t("flash.platform.cancel_mass_build") - redirect_to mass_builds_platform_path(@mass_build.platform) - 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 diff --git a/app/models/ability.rb b/app/models/ability.rb index 68b5d7375..6a4642878 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -83,7 +83,9 @@ 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, :cancel_mass_build, :failed_builds_list] , Platform) {|platform| owner? platform} + can([:destroy, :members, :add_member, :remove_member, :remove_members, :build_all, :mass_builds] , Platform) {|platform| owner?(platform) || local_admin?(platform) } + can(:failed_builds_list, MassBuild) {|mass_build| owner?(mass_build.platform) || local_admin?(mass_build.platform) } + can(:cancel_mass_build, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build } can [:autocomplete_user_uname, :read_advisories, :advisories], Platform can [:read, :projects_list], Repository, :platform => {:visibility => 'open'} @@ -127,7 +129,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, :cancel_mass_build, :failed_builds_list], Platform, :platform_type => 'personal' + cannot [:clone, :build_all, :mass_builds], Platform, :platform_type => 'personal' + cannot(:failed_builds_list, MassBuild) {|mass_build| mass_build.platform.platform_type == 'personal'} + cannot(:cancel_mass_build, MassBuild) { |mass_build| mass_build.platform.platform_type == 'personal' && mass_build.stop_build } can :create, Subscribe do |subscribe| !subscribe.subscribeable.subscribes.exists?(:user_id => user.id) diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index ff3124678..b8a2a8fde 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -57,5 +57,5 @@ class MassBuild < ActiveRecord::Base bl.cancel end end - later :cancel_all, :loner => true, :queue => :clone_build + later :cancel_all, :queue => :clone_build end diff --git a/app/views/platforms/platforms/build_all.html.haml b/app/views/platforms/platforms/build_all.html.haml index 072151269..a02cff527 100644 --- a/app/views/platforms/platforms/build_all.html.haml +++ b/app/views/platforms/platforms/build_all.html.haml @@ -43,8 +43,8 @@ = 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.cancel_mass_build"), cancel_mass_build_platforms_path(:mass_build_id => mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") + %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_mass_build_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel_mass_build, 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 }"} diff --git a/config/routes.rb b/config/routes.rb index d9186bbd2..c777392b3 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -55,10 +55,14 @@ Rosa::Application.routes.draw do get :mass_builds get :advisories end - collection do - get :failed_builds_list - post :cancel_mass_build + + resources :mass_builds do + member do + get :failed_builds_list + post :cancel_mass_build + end end + get :autocomplete_user_uname, :on => :collection resources :repositories do member do From c7232c53e991dce3fcec311af9b86afb05604d6a Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 3 Jul 2012 12:44:51 +0400 Subject: [PATCH 08/14] [refs #442] Fix some locales. Fix batch_size --- app/models/mass_build.rb | 2 +- config/locales/models/mass_build.en.yml | 4 ++-- config/locales/models/mass_build.ru.yml | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index b8a2a8fde..70e3a86c7 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -53,7 +53,7 @@ class MassBuild < ActiveRecord::Base def cancel_all self.update_attribute(:stop_build, true) - self.build_lists.find_each do |bl| + self.build_lists.find_each(:batch_size => 100) do |bl| bl.cancel end end diff --git a/config/locales/models/mass_build.en.yml b/config/locales/models/mass_build.en.yml index 39419e928..734172bcc 100644 --- a/config/locales/models/mass_build.en.yml +++ b/config/locales/models/mass_build.en.yml @@ -6,7 +6,7 @@ en: failed_builds_list: Failed Builds List statuses: Statuses cancel_mass_build: Cancel - cancel_confirm: Are you sure you want to cancel all builds? + cancel_confirm: Are you sure you want to cancel mass build? activerecord: models: mass_build: Mass Build @@ -20,4 +20,4 @@ en: user: User auto_publish: Auto Publish repositories: Repositories - rep_names: Repository names + rep_names: Repositories diff --git a/config/locales/models/mass_build.ru.yml b/config/locales/models/mass_build.ru.yml index e4144b94e..5e7cc7c38 100644 --- a/config/locales/models/mass_build.ru.yml +++ b/config/locales/models/mass_build.ru.yml @@ -6,7 +6,7 @@ ru: failed_builds_list: Список ошибок сборок statuses: Статусы cancel_mass_build: Отмена - cancel_confirm: Вы уверены, что хотите отменить все сборки? + cancel_confirm: Вы уверены, что хотите отменить массовую сборку? activerecord: models: mass_build: Массовая Сборка @@ -20,4 +20,4 @@ ru: user: Пользователь auto_publish: Авто Публикация repositories: Репозитории - rep_names: Названия репозиториев + rep_names: Репозитории From dbbe4cef1f9cbf15dd2a036d2f2cf115c620fc52 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 3 Jul 2012 14:24:14 +0400 Subject: [PATCH 09/14] [refs #442] Slice counters migration on two parts --- .../20120622092725_add_counters_to_mass_builds.rb | 12 ++++++------ ...01719_add_null_false_to_mass_builds_counters.rb | 10 ++++++++++ db/schema.rb | 14 +++++++------- 3 files changed, 23 insertions(+), 13 deletions(-) create mode 100644 db/migrate/20120703101719_add_null_false_to_mass_builds_counters.rb diff --git a/db/migrate/20120622092725_add_counters_to_mass_builds.rb b/db/migrate/20120622092725_add_counters_to_mass_builds.rb index afed190ac..5b0ed2e73 100644 --- a/db/migrate/20120622092725_add_counters_to_mass_builds.rb +++ b/db/migrate/20120622092725_add_counters_to_mass_builds.rb @@ -1,10 +1,10 @@ class AddCountersToMassBuilds < ActiveRecord::Migration def change - add_column :mass_builds, :build_lists_count, :integer, :default => 0, :null => false - add_column :mass_builds, :build_published_count, :integer, :default => 0, :null => false - add_column :mass_builds, :build_pending_count, :integer, :default => 0, :null => false - add_column :mass_builds, :build_started_count, :integer, :default => 0, :null => false - add_column :mass_builds, :build_publish_count, :integer, :default => 0, :null => false - add_column :mass_builds, :build_error_count, :integer, :default => 0, :null => false + add_column :mass_builds, :build_lists_count, :integer, :default => 0 + add_column :mass_builds, :build_published_count, :integer, :default => 0 + add_column :mass_builds, :build_pending_count, :integer, :default => 0 + add_column :mass_builds, :build_started_count, :integer, :default => 0 + add_column :mass_builds, :build_publish_count, :integer, :default => 0 + add_column :mass_builds, :build_error_count, :integer, :default => 0 end end diff --git a/db/migrate/20120703101719_add_null_false_to_mass_builds_counters.rb b/db/migrate/20120703101719_add_null_false_to_mass_builds_counters.rb new file mode 100644 index 000000000..6ae37a904 --- /dev/null +++ b/db/migrate/20120703101719_add_null_false_to_mass_builds_counters.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index f2b1060c5..ce770d06a 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 => 20120629134216) do +ActiveRecord::Schema.define(:version => 20120703101719) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -204,12 +204,12 @@ ActiveRecord::Schema.define(:version => 20120629134216) 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 From 0827cf5100224a3a779d8979bfa047c1f4577920 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Tue, 3 Jul 2012 18:34:07 +0400 Subject: [PATCH 10/14] [refs #442] Add other mass builds action to mass_builds controller. Rename cancel_mass_builds action --- app/controllers/mass_builds_controller.rb | 37 ++++++++++++++++++- .../platforms/platforms_controller.rb | 24 ------------ app/models/ability.rb | 12 +++--- .../index.html.haml} | 8 ++-- app/views/platforms/base/_sidebar.html.haml | 6 +-- config/routes.rb | 6 +-- 6 files changed, 50 insertions(+), 43 deletions(-) rename app/views/{platforms/platforms/build_all.html.haml => mass_builds/index.html.haml} (88%) diff --git a/app/controllers/mass_builds_controller.rb b/app/controllers/mass_builds_controller.rb index 441b04503..8f2ec3770 100644 --- a/app/controllers/mass_builds_controller.rb +++ b/app/controllers/mass_builds_controller.rb @@ -1,12 +1,45 @@ class MassBuildsController < ApplicationController before_filter :authenticate_user! + load_and_authorize_resource :platform load_and_authorize_resource - def cancel_mass_build + 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 :action => :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 mass_builds_platform_path(@mass_build.platform) + redirect_to platform_mass_builds_path(@mass_build.platform) end def failed_builds_list diff --git a/app/controllers/platforms/platforms_controller.rb b/app/controllers/platforms/platforms_controller.rb index 09dde90c3..5a948d06e 100644 --- a/app/controllers/platforms/platforms_controller.rb +++ b/app/controllers/platforms/platforms_controller.rb @@ -7,30 +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 index @platforms = @platforms.accessible_by(current_ability, :related).paginate(:page => params[:page], :per_page => 20) end diff --git a/app/models/ability.rb b/app/models/ability.rb index 6a4642878..f087ce699 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -83,9 +83,9 @@ 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) || local_admin?(platform) } - can(:failed_builds_list, MassBuild) {|mass_build| owner?(mass_build.platform) || local_admin?(mass_build.platform) } - can(:cancel_mass_build, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build } + can([:destroy, :members, :add_member, :remove_member, :remove_members] , Platform) {|platform| owner?(platform) || local_admin?(platform) } + can([:failed_builds_list, :create], MassBuild) {|mass_build| owner?(mass_build.platform) || local_admin?(mass_build.platform) } + can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build } can [:autocomplete_user_uname, :read_advisories, :advisories], Platform can [:read, :projects_list], Repository, :platform => {:visibility => 'open'} @@ -129,9 +129,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(:failed_builds_list, MassBuild) {|mass_build| mass_build.platform.platform_type == 'personal'} - cannot(:cancel_mass_build, MassBuild) { |mass_build| mass_build.platform.platform_type == 'personal' && mass_build.stop_build } + cannot [:clone], Platform, :platform_type => 'personal' + cannot([:failed_builds_list, :create], MassBuild) {|mass_build| mass_build.platform.platform_type == 'personal'} + cannot(:cancel, MassBuild) { |mass_build| mass_build.platform.platform_type == 'personal' && mass_build.stop_build } can :create, Subscribe do |subscribe| !subscribe.subscribeable.subscribes.exists?(:user_id => user.id) diff --git a/app/views/platforms/platforms/build_all.html.haml b/app/views/mass_builds/index.html.haml similarity index 88% rename from app/views/platforms/platforms/build_all.html.haml rename to app/views/mass_builds/index.html.haml index a02cff527..15ba91f7a 100644 --- a/app/views/platforms/platforms/build_all.html.haml +++ b/app/views/mass_builds/index.html.haml @@ -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| @@ -44,7 +44,7 @@ = mass_build.read_attribute "#{status}_count" .both %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_mass_build_platform_mass_build_path(@platform, mass_build.id), :method => :post, :confirm => t("layout.mass_builds.cancel_confirm") if can?(:cancel_mass_build, 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 }"} diff --git a/app/views/platforms/base/_sidebar.html.haml b/app/views/platforms/base/_sidebar.html.haml index 2ba6c1279..434e2ad43 100644 --- a/app/views/platforms/base/_sidebar.html.haml +++ b/app/views/platforms/base/_sidebar.html.haml @@ -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) diff --git a/config/routes.rb b/config/routes.rb index c777392b3..4370d907e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -51,15 +51,13 @@ Rosa::Application.routes.draw do delete :remove_member post :add_member post :make_clone - post :build_all - get :mass_builds get :advisories end - resources :mass_builds do + resources :mass_builds, :only => [:create, :index] do member do get :failed_builds_list - post :cancel_mass_build + post :cancel end end From 4eac2a232f8d20da339c7fb9464ad52a099b4c7f Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 4 Jul 2012 15:22:26 +0400 Subject: [PATCH 11/14] [refs #442] Ability rights refactor. status_by_human refactor --- app/controllers/mass_builds_controller.rb | 2 +- app/models/ability.rb | 6 ++---- app/models/build_list.rb | 2 +- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/app/controllers/mass_builds_controller.rb b/app/controllers/mass_builds_controller.rb index 8f2ec3770..10a59a6cc 100644 --- a/app/controllers/mass_builds_controller.rb +++ b/app/controllers/mass_builds_controller.rb @@ -25,7 +25,7 @@ class MassBuildsController < ApplicationController @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 :action => :index + render :index end end diff --git a/app/models/ability.rb b/app/models/ability.rb index 252bdc476..0dfd99a08 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -84,8 +84,6 @@ class Ability 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] , Platform) {|platform| owner?(platform) || local_admin?(platform) } - can([:failed_builds_list, :create], MassBuild) {|mass_build| owner?(mass_build.platform) || local_admin?(mass_build.platform) } - can(:cancel, MassBuild) {|mass_build| (owner?(mass_build.platform) || local_admin?(mass_build.platform)) && !mass_build.stop_build } can [:autocomplete_user_uname, :read_advisories, :advisories], Platform can [:read, :projects_list], Repository, :platform => {:visibility => 'open'} @@ -130,8 +128,8 @@ class Ability cannot [:create, :update, :destroy, :clone], Product, :platform => {:platform_type => 'personal'} cannot [:clone], Platform, :platform_type => 'personal' - cannot([:failed_builds_list, :create], MassBuild) {|mass_build| mass_build.platform.platform_type == 'personal'} - cannot(:cancel, MassBuild) { |mass_build| mass_build.platform.platform_type == 'personal' && mass_build.stop_build } + 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) diff --git a/app/models/build_list.rb b/app/models/build_list.rb index a02638635..d5f1db10b 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -220,7 +220,7 @@ class BuildList < ActiveRecord::Base end def self.status_by_human(human) - BuildList::HUMAN_STATUSES.each { |k,v| return k if v == human } + BuildList::HUMAN_STATUSES.key human end def set_items(items_hash) From 82612c368dd80e0ab4969aa6c4e614c14bec1802 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 4 Jul 2012 16:15:12 +0400 Subject: [PATCH 12/14] [refs #442] Move mass_builds to platforms dir --- app/controllers/{ => platforms}/mass_builds_controller.rb | 3 ++- app/views/{ => platforms}/mass_builds/index.html.haml | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename app/controllers/{ => platforms}/mass_builds_controller.rb (93%) rename app/views/{ => platforms}/mass_builds/index.html.haml (100%) diff --git a/app/controllers/mass_builds_controller.rb b/app/controllers/platforms/mass_builds_controller.rb similarity index 93% rename from app/controllers/mass_builds_controller.rb rename to app/controllers/platforms/mass_builds_controller.rb index 10a59a6cc..8564ff2ee 100644 --- a/app/controllers/mass_builds_controller.rb +++ b/app/controllers/platforms/mass_builds_controller.rb @@ -1,4 +1,5 @@ -class MassBuildsController < ApplicationController +#class MassBuildsController < ApplicationController +class Platforms::MassBuildsController < Platforms::BaseController before_filter :authenticate_user! load_and_authorize_resource :platform diff --git a/app/views/mass_builds/index.html.haml b/app/views/platforms/mass_builds/index.html.haml similarity index 100% rename from app/views/mass_builds/index.html.haml rename to app/views/platforms/mass_builds/index.html.haml From 2353a659723a206d808eb44d2a49d339ffc9cac3 Mon Sep 17 00:00:00 2001 From: "konstantin.grabar" Date: Wed, 4 Jul 2012 16:53:44 +0400 Subject: [PATCH 13/14] [refs #442] Repair schema --- db/schema.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index 3726f88c8..ccc096c75 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -17,8 +17,8 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.integer "user_id", :null => false t.string "kind" t.text "data" - t.datetime "created_at" - t.datetime "updated_at" + t.datetime "created_at", :null => false + t.datetime "updated_at", :null => false end create_table "advisories", :force => true do |t| @@ -225,7 +225,7 @@ ActiveRecord::Schema.define(:version => 20120703101719) do t.string "owner_type" t.string "visibility", :default => "open", :null => false t.string "platform_type", :default => "main", :null => false - t.string "distrib_type" + t.string "distrib_type", :null => false end add_index "platforms", ["name"], :name => "index_platforms_on_name", :unique => true, :case_sensitive => false From 8687e343f8d65fa608fdff3253e25abe0802b1d1 Mon Sep 17 00:00:00 2001 From: George Vinogradov Date: Wed, 4 Jul 2012 17:55:55 +0400 Subject: [PATCH 14/14] [issue #554] Fixed tab+space json bug in AJAX. --- app/views/platforms/repositories/_proj_ajax.js.erb | 2 +- app/views/platforms/repositories/_project.js.erb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/platforms/repositories/_proj_ajax.js.erb b/app/views/platforms/repositories/_proj_ajax.js.erb index 9fd8431d4..3b00728de 100644 --- a/app/views/platforms/repositories/_proj_ajax.js.erb +++ b/app/views/platforms/repositories/_proj_ajax.js.erb @@ -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 %> diff --git a/app/views/platforms/repositories/_project.js.erb b/app/views/platforms/repositories/_project.js.erb index fbff4878d..2dd623397 100644 --- a/app/views/platforms/repositories/_project.js.erb +++ b/app/views/platforms/repositories/_project.js.erb @@ -13,7 +13,7 @@ j(link_to("#{project.owner.respond_to?(:uname) ? project.owner.uname : project.owner.name} / #{project.name}", project)) + "").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(' '.html_safe,