From 3b3ca4f7ea800a4141e52b18c44410ecc42814d7 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 20 Sep 2013 22:21:23 +0400 Subject: [PATCH] #309: added extra_params into BuildList --- app/assets/stylesheets/design/custom.scss | 7 +++++++ app/helpers/issues_helper.rb | 6 +++--- app/models/build_list.rb | 15 ++++++++++++++- .../projects/build_lists/_new_form.html.haml | 7 +++++++ app/views/projects/build_lists/show.html.haml | 13 ++++++++++++- config/locales/models/build_list.en.yml | 6 ++++++ config/locales/models/build_list.ru.yml | 6 ++++++ ...130920133720_add_extra_params_to_build_list.rb | 5 +++++ db/schema.rb | 3 ++- 9 files changed, 62 insertions(+), 6 deletions(-) create mode 100644 db/migrate/20130920133720_add_extra_params_to_build_list.rb diff --git a/app/assets/stylesheets/design/custom.scss b/app/assets/stylesheets/design/custom.scss index 37ee3d4ee..97fb62796 100644 --- a/app/assets/stylesheets/design/custom.scss +++ b/app/assets/stylesheets/design/custom.scss @@ -1192,6 +1192,13 @@ form.mass_build { } } +#new_build_list section.right { + width: 300px; + margin-right: 150px; +} + +.full-size { width: 100%; } + .toggle { overflow: hidden; padding-top: 10px; diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index de76623a6..4a8cdf381 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -1,9 +1,9 @@ # -*- encoding : utf-8 -*- module IssuesHelper - def tracker_search_field(name, txt) + def tracker_search_field(name, txt, classes = nil) str = "" + str << "onblur=\"if(this.value==''){this.value='#{txt}';this.className='gray #{classes}';}\"" + str << "onclick=\"if(this.value=='#{txt}'){this.value='';this.className='black #{classes}';}\" class=\"gray #{classes}\">" str.html_safe end end diff --git a/app/models/build_list.rb b/app/models/build_list.rb index 964ff9f9b..1adcfd4a7 100644 --- a/app/models/build_list.rb +++ b/app/models/build_list.rb @@ -20,6 +20,7 @@ class BuildList < ActiveRecord::Base UPDATE_TYPES = %w[bugfix security enhancement recommended newpackage] RELEASE_UPDATE_TYPES = %w[bugfix security] + EXTRA_PARAMS = %w[cfg_options build_src_rpm build_rpm] validates :project_id, :project_version, :arch, :include_repos, :build_for_platform_id, :save_to_platform_id, :save_to_repository_id, :presence => true @@ -46,11 +47,12 @@ class BuildList < ActiveRecord::Base before_validation lambda { self.include_repos = include_repos.uniq if include_repos.present? }, :on => :create before_validation :prepare_extra_repositories, :on => :create before_validation :prepare_extra_build_lists, :on => :create + before_validation :prepare_extra_params, :on => :create 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_repositories, :extra_build_lists, :extra_params LIVE_TIME = 4.week # for unpublished MAX_LIVE_TIME = 3.month # for published @@ -136,6 +138,7 @@ class BuildList < ActiveRecord::Base serialize :results, Array serialize :extra_repositories, Array serialize :extra_build_lists, Array + serialize :extra_params, Hash after_commit :place_build, :on => :create after_destroy :remove_container @@ -525,4 +528,14 @@ class BuildList < ActiveRecord::Base self.extra_build_lists = bls.pluck('build_lists.id') end + def prepare_extra_params + if extra_params.present? + params = extra_params.slice(*BuildList::EXTRA_PARAMS) + params.update(params) do |k,v| + v.strip.gsub(I18n.t("activerecord.attributes.build_list.extra_params.#{k}"), '').gsub(/[^\w\s-]/, '') + end + self.extra_params = params.select{ |k,v| v.present? } + end + end + end \ No newline at end of file diff --git a/app/views/projects/build_lists/_new_form.html.haml b/app/views/projects/build_lists/_new_form.html.haml index cd7355a12..2a2f11292 100644 --- a/app/views/projects/build_lists/_new_form.html.haml +++ b/app/views/projects/build_lists/_new_form.html.haml @@ -36,6 +36,12 @@ :subject => build_list, :autocomplete_path => autocomplete_extra_build_list_autocompletes_path + %h3= t('activerecord.attributes.build_list.extra_params.label') + - BuildList::EXTRA_PARAMS.each do |field| + - text = @build_list.extra_params[field] || t("activerecord.attributes.build_list.extra_params.#{field}") + = tracker_search_field "build_list[extra_params][#{field}]", text, 'full-size' + .both + %h3= t("activerecord.attributes.build_list.preferences") - [:auto_publish, :auto_create_container].each do |kind| .both @@ -43,6 +49,7 @@ = hidden_field_tag field, false, :id => nil = check_box_tag field, true, checked = f.label kind + %br = hidden_field_tag :from_build_list_id, params[:build_list_id] if params[:build_list_id].present? = f.submit t('layout.projects.build_button'), :data => {'disable-with' => t('layout.processing')} diff --git a/app/views/projects/build_lists/show.html.haml b/app/views/projects/build_lists/show.html.haml index 2efdef033..cffaef622 100644 --- a/app/views/projects/build_lists/show.html.haml +++ b/app/views/projects/build_lists/show.html.haml @@ -74,7 +74,7 @@ .rightlist= t("layout.#{@build_list.new_core?}_") .both - if @build_list.extra_build_lists.present? || @build_list.extra_repositories.present? - .leftlist= t("activerecord.attributes.build_list.extra_repos") + .leftlist= t("activerecord.attributes.build_list.extra_repositories") .rightlist - Repository.where(:id => @build_list.extra_repositories).each do |repo| %p= link_to "#{repo.platform.name}/#{repo.name}", [repo.platform, repo] @@ -82,6 +82,17 @@ %p= link_to "#{bl.id} (#{bl.project.name} - #{bl.arch.name})", bl .both + - if @build_list.extra_params.present? + .leftlist + %h4.nomargin= t('activerecord.attributes.build_list.extra_params.label') + .rightlist + .both + - @build_list.extra_params.each do |k, v| + .leftlist= t("activerecord.attributes.build_list.extra_params.#{k}") + .rightlist= v + .both + + - if @build_list.mass_build_id.present? .leftlist= t("activerecord.attributes.mass_build_id") .rightlist= link_to @build_list.mass_build.name, platform_mass_builds_path(@build_list.save_to_platform) diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 5815b2c92..6c73c9b5f 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -37,6 +37,12 @@ en: commit_hash: Commit hash logs: Logs + extra_params: + label: Extra params + cfg_options: Options for *.cfg file + build_src_rpm: Build src.rpm + build_rpm: Build rpm + build_list/item: name: Name level: Level diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 8007d8d6e..3ba42e28b 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -36,6 +36,12 @@ ru: commit_hash: Хэш коммита logs: Логи + extra_params: + label: Дополнительные параметры + cfg_options: Параметры для *.cfg файла + build_src_rpm: Сборка src.rpm + build_rpm: Сборка rpm + build_list/item: name: Название level: Уровень diff --git a/db/migrate/20130920133720_add_extra_params_to_build_list.rb b/db/migrate/20130920133720_add_extra_params_to_build_list.rb new file mode 100644 index 000000000..6811767fb --- /dev/null +++ b/db/migrate/20130920133720_add_extra_params_to_build_list.rb @@ -0,0 +1,5 @@ +class AddExtraParamsToBuildList < ActiveRecord::Migration + def change + add_column :build_lists, :extra_params, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index 10a1fec53..964f7d9fe 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 => 20130918164616) do +ActiveRecord::Schema.define(:version => 20130920133720) do create_table "activity_feeds", :force => true do |t| t.integer "user_id", :null => false @@ -138,6 +138,7 @@ ActiveRecord::Schema.define(:version => 20130918164616) do t.text "extra_build_lists" t.integer "publisher_id" t.integer "group_id" + t.text "extra_params" end add_index "build_lists", ["advisory_id"], :name => "index_build_lists_on_advisory_id"