mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
json API for suseconferenceclient
This commit is contained in:
parent
d648ab7cb5
commit
d95d8f234b
12 changed files with 159 additions and 8 deletions
|
|
@ -2,6 +2,6 @@ class Api::V1::ConferencesController < Api::BaseController
|
|||
respond_to :json
|
||||
|
||||
def index
|
||||
respond_with Conference.all
|
||||
render :json => Conference.all, :serializer => ConferencesArraySerializer
|
||||
end
|
||||
end
|
||||
|
|
|
|||
11
app/controllers/api/v1/events_controller.rb
Normal file
11
app/controllers/api/v1/events_controller.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
class Api::V1::EventsController < Api::BaseController
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
events = Event.includes(:conference, :track, :room, :event_type, {:event_people => :person})
|
||||
unless params[:conference_id].blank?
|
||||
events = events.where("conferences.guid" => params[:conference_id])
|
||||
end
|
||||
respond_with events
|
||||
end
|
||||
end
|
||||
13
app/controllers/api/v1/rooms_controller.rb
Normal file
13
app/controllers/api/v1/rooms_controller.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class Api::V1::RoomsController < Api::BaseController
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
if params[:conference_id].blank?
|
||||
rooms = Room.all
|
||||
else
|
||||
conference = Conference.find_by_guid(params[:conference_id])
|
||||
rooms = conference.rooms
|
||||
end
|
||||
respond_with rooms
|
||||
end
|
||||
end
|
||||
14
app/controllers/api/v1/speakers_controller.rb
Normal file
14
app/controllers/api/v1/speakers_controller.rb
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
class Api::V1::SpeakersController < Api::BaseController
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
if params[:conference_id].blank?
|
||||
people = Person.joins(:event_people)
|
||||
else
|
||||
people = Person.joins(:event_people => {:event => :conference})
|
||||
people = people.where("conferences.guid" => params[:conference_id])
|
||||
end
|
||||
people = people.where("event_people.event_role" => "speaker")
|
||||
render :json => people, :each_serializer => SpeakerSerializer
|
||||
end
|
||||
end
|
||||
13
app/controllers/api/v1/tracks_controller.rb
Normal file
13
app/controllers/api/v1/tracks_controller.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class Api::V1::TracksController < Api::BaseController
|
||||
respond_to :json
|
||||
|
||||
def index
|
||||
if params[:conference_id].blank?
|
||||
tracks = Track.all
|
||||
else
|
||||
tracks = Track.joins(:conference)
|
||||
tracks = tracks.where("conferences.guid" => params[:conference_id])
|
||||
end
|
||||
respond_with tracks
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue