organization.rb
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# Represents any organization of the system and has an organization_info object to hold its info
class Organization < Profile
has_one :organization_info
belongs_to :region
has_one :validation_info
after_create do |org|
OrganizationInfo.create!(:organization_id => org.id)
end
def contact_email
self.organization_info ? self.organization_info.contact_email : nil
end
def validation_methodology
methodology = self.validation_info ? self.validation_info.validation_methodology : nil
methodology || ('<em>' + _('(not informed)') + '</em>')
end
def validation_restrictions
restrictions = self.validation_info ? self.validation_info.restrictions : nil
restrictions || ('<em>' + _('(not informed)') + '</em>')
end
def pending_validations
CreateEnterprise.pending_for(self)
end
def find_pending_validation(code)
CreateEnterprise.pending_for(self, :code => code).first
end
def processed_validations
CreateEnterprise.processed_for(self)
end
def find_processed_validation(code)
CreateEnterprise.processed_for(self, :code => code).first
end
end