community.rb
997 Bytes
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
44
45
46
47
48
49
50
51
52
class Community < Organization
N_('Community')
N_('Language')
settings_items :description
settings_items :language
xss_terminate :only => [ :name, :address, :contact_phone, :description ]
FIELDS = %w[
description
language
]
def self.fields
super + FIELDS
end
def validate
super
self.required_fields.each do |field|
if self.send(field).blank?
self.errors.add(field, _('%{fn} is mandatory'))
end
end
end
def active_fields
environment ? environment.active_community_fields : []
end
def required_fields
environment ? environment.required_community_fields : []
end
def name=(value)
super(value)
self.identifier = value.to_slug
end
def template
environment.community_template
end
def news(limit = 30, highlight = false)
recent_documents(limit, ["articles.type != ? AND articles.highlighted = ?", 'Folder', highlight])
end
def blocks_to_expire_cache
[MembersBlock]
end
end