Module: EventsHelper

Defined in:
app/helpers/events_helper.rb

Instance Method Summary collapse

Instance Method Details

#everyone_group_if_the_user_can_create_events_thereObject



15
16
17
# File 'app/helpers/events_helper.rb', line 15

def everyone_group_if_the_user_can_create_events_there
  can?(:create_event, Group.everyone) ? Group.everyone : nil
end

#first_group_the_current_user_can_create_events_forObject



11
12
13
# File 'app/helpers/events_helper.rb', line 11

def first_group_the_current_user_can_create_events_for
  current_user.groups.find_all_by_flag(:officers_parent).first.try(:parent_groups).try(:first)
end

#group_to_create_the_event_forObject



3
4
5
# File 'app/helpers/events_helper.rb', line 3

def group_to_create_the_event_for
  @group || everyone_group_if_the_user_can_create_events_there || first_group_the_current_user_can_create_events_for
end

#groups_the_current_user_can_create_events_forObject



7
8
9
# File 'app/helpers/events_helper.rb', line 7

def groups_the_current_user_can_create_events_for
  current_user.groups.find_all_by_flag(:officers_parent).collect { |op| op.parent_groups.first }
end

#title_for_events_indexObject



19
20
21
22
23
24
25
26
# File 'app/helpers/events_helper.rb', line 19

def title_for_events_index
  return t :my_events if @navable == current_user
  return t :events_on_global_website if @on_global_website
  return t :events_on_local_website if @on_local_website
  return "#{t(:events_of)} '#{@group.name}'" if @group
  return t :all_events if @all
  return t :events
end