From de2d08946fc5bfa425fb56c164f59a5f3378a1b2 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 27 Jun 2014 23:08:14 +0400 Subject: [PATCH] #405: updated UI, added extra_mass_builds to MassBuild --- app/controllers/autocompletes_controller.rb | 11 ++++++ app/models/mass_build.rb | 10 ++--- app/views/platforms/mass_builds/new.html.haml | 6 +++ .../platforms/mass_builds/show.html.haml | 38 +++++++++++++++++++ .../_extra_mass_builds.en.html.haml | 3 ++ .../_extra_mass_builds.ru.html.haml | 3 ++ config/locales/models/build_list.en.yml | 1 + config/locales/models/build_list.ru.yml | 1 + config/locales/models/mass_build.en.yml | 1 + config/locales/models/mass_build.ru.yml | 1 + config/routes.rb | 1 + ...27_add_extra_mass_builds_to_mass_builds.rb | 5 +++ db/schema.rb | 3 +- 13 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 app/views/shared/autocomplete_docs/_extra_mass_builds.en.html.haml create mode 100644 app/views/shared/autocomplete_docs/_extra_mass_builds.ru.html.haml create mode 100644 db/migrate/20140627173727_add_extra_mass_builds_to_mass_builds.rb diff --git a/app/controllers/autocompletes_controller.rb b/app/controllers/autocompletes_controller.rb index 53a7a9e84..aec8143bc 100644 --- a/app/controllers/autocompletes_controller.rb +++ b/app/controllers/autocompletes_controller.rb @@ -14,6 +14,17 @@ class AutocompletesController < ApplicationController render json: results.to_json end + def autocomplete_extra_mass_build + mb = MassBuild.where(id: params[:term]).first + results << { + id: mb.id, + value: mb.id, + label: "#{mb.id} - #{mb.name}", + path: platform_mass_build_path(mb.save_to_platform, mb) + } if mb && can?(:show, mb) + render json: results.to_json + end + def autocomplete_extra_repositories # Only personal and build for platform repositories can be attached to the build Platform.includes(:repositories).search(params[:term]).search_order diff --git a/app/models/mass_build.rb b/app/models/mass_build.rb index c99206fc0..6ec1bd378 100644 --- a/app/models/mass_build.rb +++ b/app/models/mass_build.rb @@ -9,16 +9,16 @@ class MassBuild < ActiveRecord::Base serialize :extra_repositories, Array serialize :extra_build_lists, Array + serialize :extra_mass_builds, Array - scope :recent, -> { order(created_at: :desc) } - scope :by_platform, -> (platform) { where(save_to_platform_id: platform.id) } - scope :outdated, -> { where("#{table_name}.created_at < ?", Time.now + 1.day - BuildList::MAX_LIVE_TIME) } - scope :search, -> (q) { where("#{table_name}.description ILIKE ?", "%#{q}%") if q.present? } + scope :recent, -> { order(created_at: :desc) } + scope :outdated, -> { where("#{table_name}.created_at < ?", Time.now + 1.day - BuildList::MAX_LIVE_TIME) } + scope :search, -> (q) { where("#{table_name}.description ILIKE ?", "%#{q}%") if q.present? } attr_accessor :arches 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 + :use_cached_chroot, :use_extra_tests, :description, :extra_mass_builds validates :save_to_platform_id, :build_for_platform_id, diff --git a/app/views/platforms/mass_builds/new.html.haml b/app/views/platforms/mass_builds/new.html.haml index e514e9dbc..e82b1f571 100644 --- a/app/views/platforms/mass_builds/new.html.haml +++ b/app/views/platforms/mass_builds/new.html.haml @@ -36,6 +36,12 @@ placeholder: 'uxteam_personal', subject: @mass_build, autocomplete_path: autocomplete_extra_repositories_autocompletes_path + = render 'shared/autocomplete_form', + field: :extra_mass_builds, + field_class: MassBuild, + placeholder: '1000000', + subject: @mass_build, + autocomplete_path: autocomplete_extra_mass_build_autocompletes_path = render 'shared/autocomplete_form', field: :extra_build_lists, field_class: BuildList, diff --git a/app/views/platforms/mass_builds/show.html.haml b/app/views/platforms/mass_builds/show.html.haml index 8efe5c7a7..b0038a13d 100644 --- a/app/views/platforms/mass_builds/show.html.haml +++ b/app/views/platforms/mass_builds/show.html.haml @@ -18,6 +18,10 @@ %td %b= t('activerecord.attributes.mass_build.arch_names') %td= @mass_build.arch_names + %tr + %td + %b= t('activerecord.attributes.mass_build.build_for_platform') + %td= link_to @mass_build.build_for_platform.name, platform_path(@mass_build.build_for_platform) %tr %td %b= t('activerecord.attributes.mass_build.auto_publish_status') @@ -42,6 +46,40 @@ %td %b= t('activerecord.attributes.mass_build.description') %td= @mass_build.description + + %tr + %td + %b= t("activerecord.attributes.build_list.extra_repositories") + %td + - if @mass_build.extra_repositories.present? + - Repository.where(id: @mass_build.extra_repositories).each do |repo| + %p= link_to "#{repo.platform.name}/#{repo.name}", [repo.platform, repo] + .both + - else + = t('layout.false_') + + %tr + %td + %b= t("activerecord.attributes.build_list.extra_mass_builds") + %td + - if @mass_build.extra_mass_builds.present? + - MassBuild.where(id: @mass_build.extra_mass_builds).each do |mb| + %p= link_to "#{mb.id} - #{mb.name}", platform_mass_build_path(mb.save_to_platform, mb) + .both + - else + = t('layout.false_') + + %tr + %td + %b= t("activerecord.attributes.build_list.extra_build_lists") + %td + - if @mass_build.extra_build_lists.present? + - BuildList.where(id: @mass_build.extra_build_lists).each do |bl| + %p= link_to "#{bl.id} (#{bl.project.name} - #{bl.arch.name})", bl + .both + - else + = t('layout.false_') + %tr %td %td diff --git a/app/views/shared/autocomplete_docs/_extra_mass_builds.en.html.haml b/app/views/shared/autocomplete_docs/_extra_mass_builds.en.html.haml new file mode 100644 index 000000000..8f3328b3a --- /dev/null +++ b/app/views/shared/autocomplete_docs/_extra_mass_builds.en.html.haml @@ -0,0 +1,3 @@ +:markdown + + __Ability to attach at assembly packages of mass builds as additional sources of packages.__ \ No newline at end of file diff --git a/app/views/shared/autocomplete_docs/_extra_mass_builds.ru.html.haml b/app/views/shared/autocomplete_docs/_extra_mass_builds.ru.html.haml new file mode 100644 index 000000000..80fd5c9b0 --- /dev/null +++ b/app/views/shared/autocomplete_docs/_extra_mass_builds.ru.html.haml @@ -0,0 +1,3 @@ +:markdown + + __Возможность подключить для сборки пакеты из массовой сборки как дополнительные источники пакетов.__ \ No newline at end of file diff --git a/config/locales/models/build_list.en.yml b/config/locales/models/build_list.en.yml index 9dd42ba0a..978c94c89 100644 --- a/config/locales/models/build_list.en.yml +++ b/config/locales/models/build_list.en.yml @@ -9,6 +9,7 @@ en: name: Name extra_repositories: Extra repositories extra_build_lists: Extra build lists + extra_mass_builds: Extra mass builds auto_create_container: Create container automatically use_cached_chroot: Use cached chroot use_extra_tests: Use extra tests diff --git a/config/locales/models/build_list.ru.yml b/config/locales/models/build_list.ru.yml index 3259e7f57..48a74d3b1 100644 --- a/config/locales/models/build_list.ru.yml +++ b/config/locales/models/build_list.ru.yml @@ -9,6 +9,7 @@ ru: name: Название extra_repositories: Дополнительные репозитории extra_build_lists: Дополнительные сборки + extra_mass_builds: Дополнительные массовые сборки auto_create_container: Создать контейнер автоматически use_cached_chroot: Использовать кэшированный chroot use_extra_tests: Использовать дополнительные тесты diff --git a/config/locales/models/mass_build.en.yml b/config/locales/models/mass_build.en.yml index adb4e5ae1..e1624d218 100644 --- a/config/locales/models/mass_build.en.yml +++ b/config/locales/models/mass_build.en.yml @@ -37,3 +37,4 @@ en: use_extra_tests: Use extra tests repositories: Repositories projects_list: Projects list + build_for_platform: Build for platform diff --git a/config/locales/models/mass_build.ru.yml b/config/locales/models/mass_build.ru.yml index eb6703abc..b7fc7907f 100644 --- a/config/locales/models/mass_build.ru.yml +++ b/config/locales/models/mass_build.ru.yml @@ -38,3 +38,4 @@ ru: use_extra_tests: Использовать дополнительные тесты repositories: Репозитории projects_list: Список проектов + build_for_platform: Собрано для платформы diff --git a/config/routes.rb b/config/routes.rb index 7995cd20e..7e1082caa 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -230,6 +230,7 @@ Rosa::Application.routes.draw do get :autocomplete_user_uname get :autocomplete_group_uname get :autocomplete_extra_build_list + get :autocomplete_extra_mass_build get :autocomplete_extra_repositories end end diff --git a/db/migrate/20140627173727_add_extra_mass_builds_to_mass_builds.rb b/db/migrate/20140627173727_add_extra_mass_builds_to_mass_builds.rb new file mode 100644 index 000000000..ed374708d --- /dev/null +++ b/db/migrate/20140627173727_add_extra_mass_builds_to_mass_builds.rb @@ -0,0 +1,5 @@ +class AddExtraMassBuildsToMassBuilds < ActiveRecord::Migration + def change + add_column :mass_builds, :extra_mass_builds, :text + end +end diff --git a/db/schema.rb b/db/schema.rb index d09562288..9bf968bd9 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: 20140627162053) do +ActiveRecord::Schema.define(version: 20140627173727) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -328,6 +328,7 @@ ActiveRecord::Schema.define(version: 20140627162053) do t.boolean "use_extra_tests", default: false, null: false t.string "description" t.string "auto_publish_status", default: "none", null: false + t.text "extra_mass_builds" end create_table "users", force: true do |t|