members_block.rb
742 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
class MembersBlock < ProfileListBlock
def self.description
_('Members')
end
def default_title
_('{#} members')
end
def help
_('This block presents the members of a collective.')
end
def footer
profile = self.owner
lambda do
link_to _('View all'), :profile => profile.identifier, :controller => 'profile', :action => 'members'
end
end
def profile_count
owner.members.select {|member| member.visible? }.count
end
def profile_finder
@profile_finder ||= MembersBlock::Finder.new(self)
end
# Finds random members, up to the limit.
class Finder < ProfileListBlock::Finder
def ids
block.owner.members.select {|member| member.visible? }.map(&:id)
end
end
end