diff --git a/app/controllers/platforms/product_build_lists_controller.rb b/app/controllers/platforms/product_build_lists_controller.rb index 51ebfb1a9..3087736e7 100644 --- a/app/controllers/platforms/product_build_lists_controller.rb +++ b/app/controllers/platforms/product_build_lists_controller.rb @@ -6,7 +6,7 @@ class Platforms::ProductBuildListsController < Platforms::BaseController load_and_authorize_resource :platform, :except => :index load_and_authorize_resource :product, :through => :platform, :except => :index load_and_authorize_resource :product_build_list, :through => :product, :except => :index - load_and_authorize_resource :only => [:index, :show, :log, :cancel] + load_and_authorize_resource :only => [:index, :show, :log, :cancel, :update] def new product = @product_build_list.product @@ -23,6 +23,16 @@ class Platforms::ProductBuildListsController < Platforms::BaseController def show end + def update + if @product_build_list.update_attributes(params[:product_build_list]) + flash[:notice] = t('flash.product_build_list.updated') + else + flash[:error] = t('flash.product_build_list.update_error') + flash[:warning] = @product_build_list.errors.full_messages.join('. ') + end + redirect_to platform_product_product_build_list_path(@platform, @product, @product_build_list) + end + def cancel if @product_build_list.cancel notice = t('layout.build_lists.will_be_canceled') diff --git a/app/models/ability.rb b/app/models/ability.rb index f7d26c011..951a28fc7 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -117,7 +117,7 @@ class Ability can(:read, Product, read_relations_for('products', 'platforms')) {|product| product.platform.main?} can([:create, :update, :destroy, :clone], Product) {|product| local_admin? product.platform and product.platform.main?} - can([:create, :cancel], ProductBuildList) {|pbl| can?(:update, pbl.product)} + can([:create, :cancel, :update], ProductBuildList) {|pbl| can?(:update, pbl.product)} can(:destroy, ProductBuildList) {|pbl| can?(:destroy, pbl.product)} can [:read, :create], PrivateUser, :platform => {:owner_type => 'User', :owner_id => user.id} diff --git a/app/models/product_build_list.rb b/app/models/product_build_list.rb index 7eff2f790..3420249e7 100644 --- a/app/models/product_build_list.rb +++ b/app/models/product_build_list.rb @@ -54,7 +54,8 @@ class ProductBuildList < ActiveRecord::Base :commit_hash, :arch_id, :product_id, - :not_delete + :not_delete, + :autostarted attr_readonly :product_id serialize :results, Array diff --git a/app/views/platforms/product_build_lists/show.html.haml b/app/views/platforms/product_build_lists/show.html.haml index 6af23ac72..eab087bb8 100644 --- a/app/views/platforms/product_build_lists/show.html.haml +++ b/app/views/platforms/product_build_lists/show.html.haml @@ -35,6 +35,24 @@ - if pbl.build_started? || pbl.build_canceling? = render 'shared/log', { :build_started => true, :get_log_path => log_platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) } +- if pbl.build_completed? && can?(:update, pbl) + = form_for pbl, :url => platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl) do |f| + .leftlist= f.label :not_delete + .rightlist + = f.select :not_delete, [false, true].collect{|status| [t("layout.#{status}_"), status]}, {:selected => pbl.not_delete} + .both + %br + = submit_tag t('layout.update') + .both + - unless pbl.not_delete + .flash_notify + .alert.alert-error + - if pbl.autostarted? + = t('layout.product_build_lists.will_be_exist_2_weeks') + - else + = t('layout.product_build_lists.will_be_exist_3_months') + .both + = render 'results', :subject => pbl :javascript diff --git a/config/locales/models/product_build_list.en.yml b/config/locales/models/product_build_list.en.yml index 35e45dd80..35a8ae2a5 100644 --- a/config/locales/models/product_build_list.en.yml +++ b/config/locales/models/product_build_list.en.yml @@ -1,6 +1,8 @@ en: layout: product_build_lists: + will_be_exist_2_weeks: Product build list will be exist in two weeks + will_be_exist_3_months: Product build list will be exist in three months logs: Logs (last 100 lines) work_env: Work environment iso_builder_folder: folder with contents of the GIT project @@ -29,6 +31,7 @@ en: activerecord: attributes: product_build_list: + not_delete: Not delete id: Id user: User product: Product @@ -52,4 +55,6 @@ en: product_build_list: no_project: Project for build should be exist delete: Product build list deleted - delete_error: Unable to delete product build list \ No newline at end of file + delete_error: Unable to delete product build list + updated: Product build list updated + update_error: Unable to update product build list \ No newline at end of file diff --git a/config/locales/models/product_build_list.ru.yml b/config/locales/models/product_build_list.ru.yml index 9741cd1b3..baecbdfb4 100644 --- a/config/locales/models/product_build_list.ru.yml +++ b/config/locales/models/product_build_list.ru.yml @@ -1,6 +1,8 @@ ru: layout: product_build_lists: + will_be_exist_2_weeks: Cборочный лист продукта будет доступен в течение двух недель + will_be_exist_3_months: Cборочный лист продукта будет доступен в течение трех месяцев logs: Логи (последнии 100 строк) work_env: Рабочее пространство iso_builder_folder: папка с содержимым GIT проекта @@ -29,6 +31,7 @@ ru: activerecord: attributes: product_build_list: + not_delete: Не удалять id: Id user: Пользователь product: Продукт @@ -52,4 +55,6 @@ ru: product_build_list: no_project: Проект для сборки должен присутствовать delete: Сборочный лист продукта удален - delete_error: Не удалось удалить cборочный лист продукта \ No newline at end of file + delete_error: Не удалось удалить cборочный лист продукта + updated: Cборочный лист продукта успешно обновлен + update_error: Не удалось обновить cборочный лист продукта \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 4d5e5c11c..e3882c1c9 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -162,7 +162,7 @@ Rosa::Application.routes.draw do end resources :key_pairs, :only => [:create, :index, :destroy] resources :products do - resources :product_build_lists, :only => [:create, :destroy, :new, :show] do + resources :product_build_lists, :only => [:create, :destroy, :new, :show, :update] do member { get :log put :cancel diff --git a/db/migrate/20130322132919_add_autostart_and_not_delete_to_product_and_product_build_list.rb b/db/migrate/20130322132919_autostart_iso_build_on_regular_basis.rb similarity index 53% rename from db/migrate/20130322132919_add_autostart_and_not_delete_to_product_and_product_build_list.rb rename to db/migrate/20130322132919_autostart_iso_build_on_regular_basis.rb index d62e9df50..a52c4877b 100644 --- a/db/migrate/20130322132919_add_autostart_and_not_delete_to_product_and_product_build_list.rb +++ b/db/migrate/20130322132919_autostart_iso_build_on_regular_basis.rb @@ -1,6 +1,7 @@ -class AddAutostartAndNotDeleteToProductAndProductBuildList < ActiveRecord::Migration +class AutostartIsoBuildOnRegularBasis < ActiveRecord::Migration def change add_column :products, :autostart, :integer, :default => nil add_column :product_build_lists, :not_delete, :boolean, :default => false + add_column :product_build_lists, :autostarted, :boolean, :default => false end end diff --git a/db/schema.rb b/db/schema.rb index 4383777d7..355e77730 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -315,6 +315,7 @@ ActiveRecord::Schema.define(:version => 20130322132919) do t.integer "time_living" t.integer "user_id" t.boolean "not_delete", :default => false + t.boolean "autostarted", :default => false end add_index "product_build_lists", ["product_id"], :name => "index_product_build_lists_on_product_id"