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
|
# File 'app/models/dm_event/concerns/ability.rb', line 14
def dm_event_abilities(user)
if user
if user.has_role?(:event_manager)
can :manage_events, :all
can :manage_event_registrations, :all
can :manage_event_finances, :all
can :access_event_section, :all
can :list_events, :all
can :access_admin, :all
elsif user.has_role?(:event_manager_alacarte)
can :access_event_section, :all
can :access_admin, :all
manage_event_ids = @user_roles.select {|r| r.name == 'manage_event' && r.resource_type == 'Workshop'}.map(&:resource_id)
can :manage_events, Workshop, id: manage_event_ids
manage_event_registration_ids = @user_roles.select {|r| r.name == 'manage_event_registration' && r.resource_type == 'Workshop'}.map(&:resource_id)
can :manage_event_registrations, Workshop, id: manage_event_registration_ids
manage_event_finance_ids = @user_roles.select {|r| r.name == 'manage_event_finance' && r.resource_type == 'Workshop'}.map(&:resource_id)
can :manage_event_finances, Workshop, id: manage_event_finance_ids
can :list_events, Workshop, id: (manage_event_ids + manage_event_registration_ids + manage_event_finance_ids).uniq
end
end
end
|