Commit 1ee193f2ee9cc511383dcf7d116ca91542cdf036
1 parent
89caaf77
Exists in
master
and in
29 other branches
ActionItem16: Organization's got a contact_email from their OrganizationInfo
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@812 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
4 changed files
with
14 additions
and
0 deletions
Show diff stats
app/models/organization.rb
@@ -10,6 +10,10 @@ class Organization < Profile | @@ -10,6 +10,10 @@ class Organization < Profile | ||
10 | OrganizationInfo.create!(:organization_id => org.id) | 10 | OrganizationInfo.create!(:organization_id => org.id) |
11 | end | 11 | end |
12 | 12 | ||
13 | + def contact_email | ||
14 | + self.organization_info ? self.organization_info.contact_email : nil | ||
15 | + end | ||
16 | + | ||
13 | def validation_methodology | 17 | def validation_methodology |
14 | methodology = self.validation_info ? self.validation_info.validation_methodology : nil | 18 | methodology = self.validation_info ? self.validation_info.validation_methodology : nil |
15 | methodology || ('<em>' + _('(not informed)') + '</em>') | 19 | methodology || ('<em>' + _('(not informed)') + '</em>') |
app/models/organization_info.rb
@@ -2,4 +2,6 @@ class OrganizationInfo < ActiveRecord::Base | @@ -2,4 +2,6 @@ class OrganizationInfo < ActiveRecord::Base | ||
2 | belongs_to :organization | 2 | belongs_to :organization |
3 | 3 | ||
4 | validates_numericality_of :foundation_year, :only_integer => true, :allow_nil => true | 4 | validates_numericality_of :foundation_year, :only_integer => true, :allow_nil => true |
5 | + | ||
6 | + validates_format_of :contact_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => (lambda { |info| ! info.contact_email.nil? }) | ||
5 | end | 7 | end |
db/migrate/008_create_organization_infos.rb
@@ -3,6 +3,7 @@ class CreateOrganizationInfos < ActiveRecord::Migration | @@ -3,6 +3,7 @@ class CreateOrganizationInfos < ActiveRecord::Migration | ||
3 | create_table :organization_infos do |t| | 3 | create_table :organization_infos do |t| |
4 | t.column :organization_id, :integer | 4 | t.column :organization_id, :integer |
5 | t.column :contact_person, :string | 5 | t.column :contact_person, :string |
6 | + t.column :contact_email, :string | ||
6 | t.column :acronym, :string | 7 | t.column :acronym, :string |
7 | t.column :foundation_year, :integer, :limit => 4 | 8 | t.column :foundation_year, :integer, :limit => 4 |
8 | t.column :legal_form, :string | 9 | t.column :legal_form, :string |
test/unit/organization_test.rb
@@ -53,4 +53,11 @@ class OrganizationTest < Test::Unit::TestCase | @@ -53,4 +53,11 @@ class OrganizationTest < Test::Unit::TestCase | ||
53 | assert_equal 'something', org.validation_restrictions | 53 | assert_equal 'something', org.validation_restrictions |
54 | end | 54 | end |
55 | 55 | ||
56 | + should 'override contact_email to get it from organization_info' do | ||
57 | + org = Organization.new | ||
58 | + assert_nil org.contact_email | ||
59 | + org.organization_info = OrganizationInfo.new(:contact_email => 'test@example.com') | ||
60 | + assert_equal 'test@example.com', org.contact_email | ||
61 | + end | ||
62 | + | ||
56 | end | 63 | end |