Merge pull request #602 from warpc/601-add_status_check_for_product_bl_remove
[refs #601] Add status check for destroy action in product build list
This commit is contained in:
commit
710fef1f0b
|
@ -23,8 +23,11 @@ class Platforms::ProductBuildListsController < Platforms::BaseController
|
|||
end
|
||||
|
||||
def destroy
|
||||
@product_build_list.destroy
|
||||
flash[:notice] = t('flash.product.build_list_delete')
|
||||
if @product_build_list.destroy
|
||||
flash[:notice] = t('flash.product_build_list.delete')
|
||||
else
|
||||
flash[:error] = t('flash.product_build_list.delete_error')
|
||||
end
|
||||
redirect_to [@platform, @product]
|
||||
end
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ class ProductBuildList < ActiveRecord::Base
|
|||
scope :recent, order("#{table_name}.updated_at DESC")
|
||||
|
||||
after_create :xml_rpc_create
|
||||
before_destroy :can_destroy?
|
||||
after_destroy :xml_delete_iso_container
|
||||
|
||||
def container_path
|
||||
|
@ -49,6 +50,10 @@ class ProductBuildList < ActiveRecord::Base
|
|||
self.class.human_status(status)
|
||||
end
|
||||
|
||||
def can_destroy?
|
||||
[BUILD_COMPLETED, BUILD_FAILED].include? status
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def xml_rpc_create
|
||||
|
|
|
@ -3,5 +3,6 @@
|
|||
%td= product_build_list.human_status
|
||||
%td= link_to nil, product_build_list.container_path
|
||||
%td= link_to product_build_list.product.name, platform_product_path(product_build_list.product.platform, product_build_list.product)
|
||||
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(product_build_list.product.platform, product_build_list.product, product_build_list), :method => :delete, :confirm => t("layout.confirm") if can? :destroy, product_build_list
|
||||
- pbl = product_build_list
|
||||
%td= link_to image_tag('x.png'), platform_product_product_build_list_path(pbl.product.platform, pbl.product, pbl), :method => :delete, :confirm => t("layout.confirm") if can?(:destroy, pbl) && pbl.can_destroy?
|
||||
%td= l(product_build_list.updated_at, :format => :long)
|
|
@ -33,7 +33,6 @@ en:
|
|||
save_error: Unable to save product
|
||||
build_started: Product build started
|
||||
destroyed: Product deleted
|
||||
build_list_delete: Product build list deleted
|
||||
|
||||
activerecord:
|
||||
models:
|
||||
|
|
|
@ -33,7 +33,6 @@ ru:
|
|||
save_error: Не удалось сохранить изменения
|
||||
build_started: Запущена сборка продукта
|
||||
destroyed: Продукт удален
|
||||
build_list_delete: Сборочный лист продукта удален
|
||||
|
||||
activerecord:
|
||||
models:
|
||||
|
|
|
@ -25,6 +25,10 @@ en:
|
|||
product: Product
|
||||
container_path: Container
|
||||
status: Status
|
||||
notified_at: Notified at
|
||||
user: User
|
||||
notified_at: Notified at
|
||||
|
||||
flash:
|
||||
product_build_list:
|
||||
delete: Product build list deleted
|
||||
delete_error: Unable to delete product build list
|
|
@ -28,3 +28,8 @@ ru:
|
|||
user: Пользователь
|
||||
notified_at: Информация получена
|
||||
|
||||
flash:
|
||||
product_build_list:
|
||||
delete: Сборочный лист продукта удален
|
||||
delete_error: Не удалось удалить cборочный лист продукта
|
||||
|
||||
|
|
Loading…
Reference in New Issue