diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 9ef414fda..eb116fe68 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -1182,11 +1182,12 @@ div#advisory_search_block div.continue_input { form.mass_build { section.left { margin-left: 10px; - width: 350px; + width: 250px; } section.right { margin-right: 50px; + width: 300px; } input[type="submit"] { margin: 10px 0 10px 0; diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 2c50e4a77..106bdbd5a 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -32,10 +32,11 @@ class BuildList < ActiveRecord::Base EXTRA_PARAMS = %w[cfg_options cfg_urpm_options build_src_rpm build_rpm] EXTERNAL_NODES = %w[owned everything] - AUTO_PUBLISH_STATUS_NONE = 'none' - AUTO_PUBLISH_STATUS_DEFAULT = 'default' - AUTO_PUBLISH_STATUS_TESTING = 'testing' - AUTO_PUBLISH_STATUSES = [AUTO_PUBLISH_STATUS_NONE, AUTO_PUBLISH_STATUS_DEFAULT, AUTO_PUBLISH_STATUS_TESTING] + AUTO_PUBLISH_STATUSES = [ + AUTO_PUBLISH_STATUS_NONE = 'none', + AUTO_PUBLISH_STATUS_DEFAULT = 'default', + AUTO_PUBLISH_STATUS_TESTING = 'testing' + ] validates :project_id, :project_version, diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index bdcea55c1..c99206fc0 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -1,4 +1,7 @@ class MassBuild < ActiveRecord::Base + + AUTO_PUBLISH_STATUSES = %w(none default testing) + belongs_to :build_for_platform, -> { where(platform_type: 'main') }, class_name: 'Platform' belongs_to :save_to_platform, class_name: 'Platform' belongs_to :user @@ -13,7 +16,7 @@ class MassBuild < ActiveRecord::Base scope :search, -> (q) { where("#{table_name}.description ILIKE ?", "%#{q}%") if q.present? } attr_accessor :arches - attr_accessible :arches, :auto_publish, :projects_list, :build_for_platform_id, + attr_accessible :arches, :auto_publish_status, :projects_list, :build_for_platform_id, :extra_repositories, :extra_build_lists, :increase_release_tag, :use_cached_chroot, :use_extra_tests, :description @@ -31,8 +34,10 @@ class MassBuild < ActiveRecord::Base validates :description, length: { maximum: 255 } - validates :auto_publish, - :increase_release_tag, + validates :auto_publish_status, + inclusion: { in: AUTO_PUBLISH_STATUSES } + + validates :increase_release_tag, :use_cached_chroot, :use_extra_tests, inclusion: { in: [true, false] } diff --git a/app/models/project.rb b/app/models/project.rb index 7b9f1b987..a89636ef5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -188,7 +188,7 @@ class Project < ActiveRecord::Base bl.arch = arch bl.project_version = project_version bl.user = user - bl.auto_publish_status = mass_build.auto_publish? ? BuildList::AUTO_PUBLISH_STATUS_DEFAULT : BuildList::AUTO_PUBLISH_STATUS_NONE + bl.auto_publish_status = mass_build.auto_publish_status bl.include_repos = include_repos bl.extra_repositories = mass_build.extra_repositories bl.extra_build_lists = mass_build.extra_build_lists diff --git a/app/views/platforms/mass_builds/new.html.haml b/app/views/platforms/mass_builds/new.html.haml index 958c7cf16..e514e9dbc 100644 --- a/app/views/platforms/mass_builds/new.html.haml +++ b/app/views/platforms/mass_builds/new.html.haml @@ -43,7 +43,10 @@ subject: @mass_build, autocomplete_path: autocomplete_extra_build_list_autocompletes_path %h3= t("activerecord.attributes.build_list.preferences") - - %i(auto_publish increase_release_tag use_cached_chroot use_extra_tests).each do |field| + .both + = f.select :auto_publish_status, auto_publish_statuses + = f.label :auto_publish_status + - %i(increase_release_tag use_cached_chroot use_extra_tests).each do |field| .both = f.check_box field = f.label field diff --git a/app/views/platforms/mass_builds/show.html.haml b/app/views/platforms/mass_builds/show.html.haml index b22574b31..8efe5c7a7 100644 --- a/app/views/platforms/mass_builds/show.html.haml +++ b/app/views/platforms/mass_builds/show.html.haml @@ -10,13 +10,38 @@ %td %b= t('activerecord.attributes.mass_build.name') %td= link_to_mass_build(@mass_build) - - - %i(id arch_names auto_publish increase_release_tag use_cached_chroot use_extra_tests created_at description).each do |field| - %tr - %td - %b= t("activerecord.attributes.mass_build.#{field}") - %td= @mass_build.send field - + %tr + %td + %b= t('activerecord.attributes.mass_build.id') + %td= @mass_build.id + %tr + %td + %b= t('activerecord.attributes.mass_build.arch_names') + %td= @mass_build.arch_names + %tr + %td + %b= t('activerecord.attributes.mass_build.auto_publish_status') + %td= t("layout.build_lists.auto_publish_status.#{@mass_build.auto_publish_status}") + %tr + %td + %b= t('activerecord.attributes.mass_build.increase_release_tag') + %td= t("layout.#{@mass_build.increase_release_tag?}_") + %tr + %td + %b= t('activerecord.attributes.mass_build.use_cached_chroot') + %td= t("layout.#{@mass_build.use_cached_chroot?}_") + %tr + %td + %b= t('activerecord.attributes.mass_build.use_extra_tests') + %td= t("layout.#{@mass_build.use_extra_tests?}_") + %tr + %td + %b= t('activerecord.attributes.mass_build.created_at') + %td= @mass_build.created_at + %tr + %td + %b= t('activerecord.attributes.mass_build.description') + %td= @mass_build.description %tr %td %td @@ -49,7 +74,7 @@ .buttons_block - if can?(:publish, @mass_build) - - unless @mass_build.auto_publish? + - unless @mass_build.auto_publish_status == BuildList::AUTO_PUBLISH_STATUS_DEFAULT = link_to t('layout.mass_builds.publish_success'), publish_platform_mass_build_path(@platform, @mass_build.id), method: :post, data: { confirm: t("layout.confirm") }, class: 'button' diff --git a/config/locales/models/mass_build.en.yml b/config/locales/models/mass_build.en.yml index c981cd4c8..adb4e5ae1 100644 --- a/config/locales/models/mass_build.en.yml +++ b/config/locales/models/mass_build.en.yml @@ -31,7 +31,7 @@ en: updated_at: Updated arch_names: Architectures user: User - auto_publish: Automated publishing + auto_publish_status: Automated publishing increase_release_tag: Increase release tag use_cached_chroot: Use cached chroot use_extra_tests: Use extra tests diff --git a/config/locales/models/mass_build.ru.yml b/config/locales/models/mass_build.ru.yml index 2d0bb4fcc..eb6703abc 100644 --- a/config/locales/models/mass_build.ru.yml +++ b/config/locales/models/mass_build.ru.yml @@ -32,7 +32,7 @@ ru: updated_at: Обновлен arch_names: Архитектуры user: Пользователь - auto_publish: Автоматическая публикация + auto_publish_status: Автоматическая публикация increase_release_tag: Увеличить release тег use_cached_chroot: Использовать кэшированный chroot use_extra_tests: Использовать дополнительные тесты diff --git a/db/migrate/20140627162053_add_auto_publish_status_to_mass_builds.rb b/db/migrate/20140627162053_add_auto_publish_status_to_mass_builds.rb new file mode 100644 index 000000000..733a05db0 --- /dev/null +++ b/db/migrate/20140627162053_add_auto_publish_status_to_mass_builds.rb @@ -0,0 +1,16 @@ +class AddAutoPublishStatusToMassBuilds < ActiveRecord::Migration + class MassBuild < ActiveRecord::Base + end + + def up + add_column :mass_builds, :auto_publish_status, :string, default: 'none', null: false + MassBuild.where(auto_publish: true).update_all(auto_publish_status: :default) + remove_column :mass_builds, :auto_publish + end + + def down + add_column :mass_builds, :auto_publish, :boolean, default: false + MassBuild.where(auto_publish_status: :default).update_all(auto_publish: true) + remove_column :mass_builds, :auto_publish_status + end +end diff --git a/db/schema.rb b/db/schema.rb index 597ef05c7..d09562288 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20140626195741) do +ActiveRecord::Schema.define(version: 20140627162053) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -308,26 +308,26 @@ ActiveRecord::Schema.define(version: 20140626195741) do end create_table "mass_builds", force: true do |t| - t.integer "build_for_platform_id", null: false + t.integer "build_for_platform_id", null: false 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", default: false, null: false - t.integer "build_lists_count", default: 0, null: false - t.boolean "stop_build", default: false, null: false + t.integer "build_lists_count", default: 0, null: false + t.boolean "stop_build", default: false, null: false t.text "projects_list" - t.integer "missed_projects_count", default: 0, null: false + t.integer "missed_projects_count", default: 0, null: false t.text "missed_projects_list" t.boolean "new_core", default: true - t.integer "save_to_platform_id", null: false + t.integer "save_to_platform_id", null: false t.text "extra_repositories" t.text "extra_build_lists" - t.boolean "increase_release_tag", default: false, null: false - t.boolean "use_cached_chroot", default: true, null: false - t.boolean "use_extra_tests", default: false, null: false + t.boolean "increase_release_tag", default: false, null: false + t.boolean "use_cached_chroot", default: true, null: false + t.boolean "use_extra_tests", default: false, null: false t.string "description" + t.string "auto_publish_status", default: "none", null: false end create_table "users", force: true do |t| diff --git a/spec/controllers/platforms/mass_builds_controller_spec.rb b/spec/controllers/platforms/mass_builds_controller_spec.rb index e7360bad4..42076a3ee 100644 --- a/spec/controllers/platforms/mass_builds_controller_spec.rb +++ b/spec/controllers/platforms/mass_builds_controller_spec.rb @@ -130,7 +130,6 @@ describe Platforms::MassBuildsController do @create_params = { mass_build: { :projects_list => @repository.projects.map(&:name).join("\n"), - :auto_publish => true, :build_for_platform_id => @platform }, :platform_id => @platform, diff --git a/spec/factories/mass_build.rb b/spec/factories/mass_build.rb index 8912a3330..579ae4cdb 100644 --- a/spec/factories/mass_build.rb +++ b/spec/factories/mass_build.rb @@ -4,7 +4,6 @@ FactoryGirl.define do association :user projects_list "first" arches { [ Arch.where(name: 'x86_64').first_or_create.id ] } - auto_publish true stop_build false end end