Module: GroupsHelper

Defined in:
app/helpers/groups_helper.rb

Instance Method Summary collapse

Instance Method Details

#can_change_group_visibility_level?(group) ⇒ Boolean


22
23
24
# File 'app/helpers/groups_helper.rb', line 22

def can_change_group_visibility_level?(group)
  can?(current_user, :change_visibility_level, group)
end

#group_icon(group) ⇒ Object


26
27
28
29
30
31
32
33
34
35
36
# File 'app/helpers/groups_helper.rb', line 26

def group_icon(group)
  if group.is_a?(String)
    group = Group.find_by(path: group)
  end

  if group && group.avatar.present?
    group.avatar.url
  else
    'no_group_avatar.png'
  end
end

#group_title(group, name = nil, url = nil) ⇒ Object


38
39
40
41
42
43
44
45
# File 'app/helpers/groups_helper.rb', line 38

def group_title(group, name = nil, url = nil)
  full_title = link_to(simple_sanitize(group.name), group_path(group))
  full_title += ' · '.html_safe + link_to(simple_sanitize(name), url) if name

   :span do
    full_title
  end
end

#leave_group_message(group) ⇒ Object


10
11
12
# File 'app/helpers/groups_helper.rb', line 10

def leave_group_message(group)
  "Are you sure you want to leave \"#{group}\" group?"
end

#remove_user_from_group_message(group, member) ⇒ Object


2
3
4
5
6
7
8
# File 'app/helpers/groups_helper.rb', line 2

def remove_user_from_group_message(group, member)
  if member.user
    "Are you sure you want to remove \"#{member.user.name}\" from \"#{group.name}\"?"
  else
    "Are you sure you want to revoke the invitation for \"#{member.invite_email}\" to join \"#{group.name}\"?"
  end
end

#should_user_see_group_roles?(user, group) ⇒ Boolean


14
15
16
17
18
19
20
# File 'app/helpers/groups_helper.rb', line 14

def should_user_see_group_roles?(user, group)
  if user
    user.is_admin? || group.members.exists?(user_id: user.id)
  else
    false
  end
end