[#6441] Block deleting deliverables on closed or locked contracts
This commit is contained in:
@@ -33,6 +33,9 @@ class Deliverable < ActiveRecord::Base
|
||||
delegate "locked?", :to => :contract, :prefix => true, :allow_nil => true
|
||||
|
||||
# Callbacks
|
||||
before_destroy :block_on_locked_contracts
|
||||
before_destroy :block_on_closed_contracts
|
||||
|
||||
def after_initialize
|
||||
self.status = "open" unless self.status.present?
|
||||
end
|
||||
@@ -139,6 +142,14 @@ class Deliverable < ActiveRecord::Base
|
||||
def noop(message="")
|
||||
end
|
||||
|
||||
def block_on_locked_contracts
|
||||
!contract_locked?
|
||||
end
|
||||
|
||||
def block_on_closed_contracts
|
||||
!contract_closed?
|
||||
end
|
||||
|
||||
def to_s
|
||||
title
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<div class="info">
|
||||
<div class="title">
|
||||
<%= link_to(l(:button_edit), edit_contract_deliverable_path(@project, contract, deliverable), :class => 'icon icon-edit') %>
|
||||
<%= link_to(l(:button_delete), contract_deliverable_path(@project, contract, deliverable), :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') %>
|
||||
<%= link_to(l(:button_delete), contract_deliverable_path(@project, contract, deliverable), :method => :delete, :confirm => l(:text_are_you_sure), :class => 'icon icon-del') if contract.open? %>
|
||||
</div>
|
||||
|
||||
<%= textilizable(deliverable, :notes) %>
|
||||
|
||||
Reference in New Issue
Block a user