Module: GroupsHelper

Defined in:
app/helpers/groups_helper.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) member_list(group = nil)



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'app/helpers/groups_helper.rb', line 2

def member_list(group=nil)
  ordered_memberships = group.memberships.approved.order('level DESC').includes(:user).to_a
  member_list = ordered_memberships.map do |membership|
    member_display = String.new
    if membership.level == Membership::LEVELS[:leader]
      member_display = "#{(:i, '', {:class => 'concertocon-user-leader tooltip-basic', 'data-tooltip-tex' => t('groups.index.leader')})} "
    end
    if can? :read, membership.user
      member_display += link_to membership.user.name, user_path(membership.user)
    else
      member_display += membership.user.name
    end
  end
  shortened_list = member_list.take(10)
  shortened_list.push "and #{link_to "#{ordered_memberships.length - 10} more", group}" if member_list.length > 10
  shortened_list.join(', ').html_safe
end