Navigation Menu

Skip to content

Commit

Permalink
Add validations for kases
Browse files Browse the repository at this point in the history
  • Loading branch information
keviniano committed Nov 16, 2011
1 parent dcfee87 commit 6f6950e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
11 changes: 9 additions & 2 deletions app/models/kase.rb
Expand Up @@ -19,10 +19,17 @@ class Kase < ActiveRecord::Base
VALID_COUNTIES = {'Clackamas' => 'C', 'Multnomah' => 'M', 'Washington' => 'W'}

validates_presence_of :customer_id
validates_presence_of :referral_type
validates_presence_of :funding_source
validates :open_date, :date => { :before_or_equal_to => Proc.new { Date.today } }
validates_presence_of :referral_source
validates_presence_of :referral_type_id
validates_presence_of :funding_source_id
validates :close_date, :date => { :after => :open_date, :before_or_equal_to => Proc.new { Date.today } }, :allow_blank => true
validates_presence_of :disposition
validates_presence_of :close_date, :if => Proc.new {|kase| kase.disposition.name != "In Progress" }
validates_inclusion_of :county, :in => VALID_COUNTIES.values
validate do |kase|
kase.errors[:disposition_id] << "cannot be 'In Progress' if case is closed" if kase.close_date.present? && kase.disposition.name == 'In Progress'
end

scope :assigned_to, lambda {|user| where(:user_id => user.id) }
scope :not_assigned_to, lambda {|user| where('user_id <> ?',user.id)}
Expand Down
4 changes: 2 additions & 2 deletions app/views/kases/_form.html.erb
Expand Up @@ -26,7 +26,7 @@

<li>
<%= f.label :referral_type_id, "Referral Source Type" %>
<%= f.collection_select :referral_type_id, @referral_types, :id, :name %>
<%= f.collection_select :referral_type_id, @referral_types, :id, :name, :prompt => '<Select Option>' %>
</li>

<li>
Expand All @@ -41,7 +41,7 @@

<li>
<%= f.label :funding_source_id, "Default Funding Source" %>
<%= f.collection_select :funding_source_id, @funding_sources, :id, :name %>
<%= f.collection_select :funding_source_id, @funding_sources, :id, :name, :prompt => '<Select Option>' %>
</li>

<li>
Expand Down
2 changes: 1 addition & 1 deletion public/stylesheets/style.css
Expand Up @@ -998,7 +998,7 @@ body.kases #page-header {
position: relative;
}

body.kases.show .delete.kase {
body.kases .delete.kase {
position: absolute;
top: 8px;
right: 10px;
Expand Down

0 comments on commit 6f6950e

Please sign in to comment.