From b3ba6555e237ad7dd55a7e0d61c0cc0e605380c6 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Thu, 7 Nov 2013 19:49:43 +0400 Subject: [PATCH] #316: added chekbox into #new action for attaching testing subrepo --- app/models/ability.rb | 2 +- app/models/build_list.rb | 4 +++- app/views/projects/build_lists/_new_form.html.haml | 2 +- app/views/projects/build_lists/show.html.haml | 3 +++ config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + ...1107152408_add_use_testing_repo_to_build_list.rb | 5 +++++ db/schema.rb | 13 +++++++------ 8 files changed, 22 insertions(+), 9 deletions(-) create mode 100644 db/migrate/20131107152408_add_use_testing_repo_to_build_list.rb diff --git a/app/models/ability.rb b/app/models/ability.rb index 29fd40ef5..229826b23 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -82,7 +82,7 @@ class Ability can [:read, :log, :related, :everything], BuildList, :project => {:owner_type => 'Group', :owner_id => user.group_ids} can([:read, :log, :everything, :list], BuildList, read_relations_for('build_lists', 'projects')) {|build_list| can? :read, build_list.project} - can(:publish_into_testing, BuildList) { |build_list| can?(:create, build_list) } + can(:publish_into_testing, BuildList) { |build_list| can?(:create, build_list) && build_list.save_to_platform.main? } can(:create, BuildList) {|build_list| build_list.project.is_package && can?(:write, build_list.project) && diff --git a/app/models/build_list.rb b/app/models/build_list.rb index cadcd0de7..245f2603c 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -56,7 +56,8 @@ class BuildList < ActiveRecord::Base attr_accessible :include_repos, :auto_publish, :build_for_platform_id, :commit_hash, :arch_id, :project_id, :save_to_repository_id, :update_type, :save_to_platform_id, :project_version, :auto_create_container, - :extra_repositories, :extra_build_lists, :extra_params, :external_nodes + :extra_repositories, :extra_build_lists, :extra_params, :external_nodes, + :include_testing_subrepository LIVE_TIME = 4.week # for unpublished MAX_LIVE_TIME = 3.month # for published @@ -449,6 +450,7 @@ class BuildList < ActiveRecord::Base ), "#{repo.platform.name}_#{repo.name}_" h["#{prefix}release"] = insert_token_to_path(path + 'release', repo.platform) h["#{prefix}updates"] = insert_token_to_path(path + 'updates', repo.platform) if repo.platform.main? + h["#{prefix}testing"] = insert_token_to_path(path + 'testing', repo.platform) if include_testing_subrepository? end end host = EventLog.current_controller.request.host_with_port rescue ::Rosa::Application.config.action_mailer.default_url_options[:host] diff --git a/app/views/projects/build_lists/_new_form.html.haml b/app/views/projects/build_lists/_new_form.html.haml index 1fcc19e79..e20a125b5 100644 --- a/app/views/projects/build_lists/_new_form.html.haml +++ b/app/views/projects/build_lists/_new_form.html.haml @@ -43,7 +43,7 @@ .both %h3= t("activerecord.attributes.build_list.preferences") - - [:auto_publish, :auto_create_container].each do |kind| + - [:auto_publish, :auto_create_container, :include_testing_subrepository].each do |kind| .both - checked, field = params[:build_list].try(:[], kind), "build_list[#{kind}]" = hidden_field_tag field, false, :id => nil diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 137bf1649..dcd29d666 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -39,6 +39,9 @@ .rightlist = link_to "#{@build_list.save_to_platform.name}/#{@build_list.save_to_repository.name}", [@build_list.save_to_platform, @build_list.save_to_repository] .both + .leftlist= t("activerecord.attributes.build_list.include_testing_subrepository") + .rightlist= t("layout.#{@build_list.include_testing_subrepository?}_") + .both .leftlist= t("activerecord.attributes.build_list.include_repos") .rightlist= (@build_list.include_repos||[]).map{|r| Repository.find(r).name}.join(', ') .both diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 1374d44fb..f637cf756 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -21,6 +21,7 @@ en: is_circle: Recurrent build updated_at: Notified at additional_repos: Additional repositories + include_testing_subrepository: "Include 'testing' subrepository" include_repos: Included repositories created_at: Created on save_to_repository: Save to repository diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 0b26c214b..d67b9faa8 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -21,6 +21,7 @@ ru: is_circle: Циклическая сборка updated_at: Информация получена additional_repos: Дополнительные репозитории + include_testing_subrepository: "Подключить 'testing' подрепозиторий" include_repos: Подключаемые репозитории created_at: Создан save_to_repository: Сохранить в репозиторий diff --git a/db/migrate/20131107152408_add_use_testing_repo_to_build_list.rb b/db/migrate/20131107152408_add_use_testing_repo_to_build_list.rb new file mode 100644 index 000000000..5c8c04a99 --- /dev/null +++ b/db/migrate/20131107152408_add_use_testing_repo_to_build_list.rb @@ -0,0 +1,5 @@ +class AddUseTestingRepoToBuildList < ActiveRecord::Migration + def change + add_column :build_lists, :include_testing_subrepository, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index 22702b865..f1c62d3a2 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 => 20131022082416) do +ActiveRecord::Schema.define(:version => 20131107152408) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -112,7 +112,7 @@ ActiveRecord::Schema.define(:version => 20131022082416) do t.datetime "notified_at" t.datetime "created_at" t.datetime "updated_at" - t.boolean "is_circle", :default => false + t.boolean "is_circle", :default => false t.text "additional_repos" t.string "name" t.string "update_type" @@ -120,20 +120,20 @@ ActiveRecord::Schema.define(:version => 20131022082416) do t.integer "save_to_platform_id" t.text "include_repos" t.integer "user_id" - t.boolean "auto_publish", :default => true + t.boolean "auto_publish", :default => true t.string "package_version" t.string "commit_hash" - t.integer "priority", :default => 0, :null => false + t.integer "priority", :default => 0, :null => false t.datetime "started_at" t.integer "duration" t.integer "advisory_id" t.integer "mass_build_id" t.integer "save_to_repository_id" t.text "results" - t.boolean "new_core", :default => true + t.boolean "new_core", :default => true t.string "last_published_commit_hash" t.integer "container_status" - t.boolean "auto_create_container", :default => false + t.boolean "auto_create_container", :default => false t.text "extra_repositories" t.text "extra_build_lists" t.integer "publisher_id" @@ -141,6 +141,7 @@ ActiveRecord::Schema.define(:version => 20131022082416) do t.text "extra_params" t.string "external_nodes" t.integer "builder_id" + t.boolean "include_testing_subrepository" end add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"