[#6441] Block editing deliverables on locked and closed contracts

This commit is contained in:
Eric Davis committed 2011-08-10 11:56:08 -07:00
1 parent be37e00f10
commit 495407f127
3 files changed
+98 -1

No files matched your search

+12
View File
@@ -21,12 +21,16 @@ class Deliverable < ActiveRecord::Base
validates_presence_of :manager
validates_inclusion_of :status, :in => ["open","locked","closed"], :allow_blank => true, :allow_nil => true
validate_on_update :validate_status_changes
validate_on_update :validate_contract_status
# Accessors
include DollarizedAttribute
dollarized_attribute :total
delegate :name, :to => :contract, :prefix => true, :allow_nil => true
delegate "open?", :to => :contract, :prefix => true, :allow_nil => true
delegate "closed?", :to => :contract, :prefix => true, :allow_nil => true
delegate "locked?", :to => :contract, :prefix => true, :allow_nil => true
# Callbacks
def after_initialize
@@ -104,6 +108,14 @@ class Deliverable < ActiveRecord::Base
errors.add_to_base(:cant_update_closed_deliverable) if closed?
end
def validate_contract_status
return if contract_open?
return if change_to_status_only?
errors.add_to_base(:cant_update_locked_contract) if contract_locked?
errors.add_to_base(:cant_update_closed_contract) if contract_closed?
end
# No operation method, useful to clean up logic with an optional message
# for documentation
def noop(message="")
+6 -1
View File
@@ -2,9 +2,14 @@
<%= javascript_tag("var i18nEndDateEmpty = '#{l(:text_end_date_empty)}'") %>
<%= javascript_tag("var i18nChangedPeriodMessage = '#{l(:text_changed_period_message)}'") %>
<% if resource.locked? || resource.closed? %>
<% if resource.locked? || resource.closed? || resource.contract_locked? || resource.contract_closed? %>
<div class="error_msg">
<% if resource.contract_locked? || resource.contract_closed? %>
<p><%= resource.contract_locked? ? l(:text_contract_locked_warning) : l(:text_contract_closed_warning) %></p>
<% end %>
<% if resource.locked? || resource.closed? %>
<p><%= resource.locked? ? l(:text_deliverable_locked_warning) : l(:text_deliverable_closed_warning) %></p>
<% end %>
</div>
<% end %>