Files
osem/app/controllers/admin/reports_controller.rb
Rishabh Singh 0785b5c7e0 Add condition for missing_speakers in a track
A user should be able to see the missing speakers of
only those events that are accessible to him.

Fixes #1942
2019-04-06 20:58:43 +05:30

25 lines
1.2 KiB
Ruby

# frozen_string_literal: true
module Admin
class ReportsController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :program, through: :conference, singleton: true
# For some reason this doesn't work, so a workaround is used
# load_and_authorize_resource :event, through: :program
def index
@events = Event.accessible_by(current_ability).where(program: @program)
@events_commercials = Commercial.where(commercialable_type: 'Event', commercialable_id: @events.pluck(:id))
@events_missing_commercial = @events.where.not(id: @events_commercials.pluck(:commercialable_id))
@events_with_requirements = @events.where.not(description: ['', nil])
attended_registrants_ids = @conference.registrations.where(attended: true).pluck(:user_id)
@missing_event_speakers = EventUser.joins(:event)
.where('event_role = ? and program_id = ?', 'speaker', @program.id)
.where.not(user_id: attended_registrants_ids)
.where(event_id: @events.pluck(:id))
.includes(:user, :event)
end
end
end