osem-fcy/app/controllers/api/v1/speakers_controller.rb

24 lines
761 B
Ruby
Raw Normal View History

2014-06-26 15:43:24 +03:00
module Api
module V1
class SpeakersController < Api::BaseController
2015-10-25 00:36:23 +03:00
load_resource :conference, find_by: :short_title
2014-06-26 15:43:24 +03:00
respond_to :json
2013-07-08 10:07:12 +02:00
# Disable forgery protection for any json requests. This is required for jsonp support
skip_before_action :verify_authenticity_token
2014-06-26 15:43:24 +03:00
def index
2015-10-25 00:36:23 +03:00
if @conference
users = User.joins(event_users: { event: { program: :conference} })
2015-10-25 00:36:23 +03:00
users = users.where(conferences: { short_title: @conference.short_title })
else
users = User.joins(:event_users)
2014-06-26 15:43:24 +03:00
end
2015-10-25 00:36:23 +03:00
users = users.where(event_users: {event_role: :speaker}).uniq
render json: users, each_serializer: SpeakerSerializer, callback: params['callback']
2014-06-26 15:43:24 +03:00
end
2013-07-08 10:07:12 +02:00
end
end
end