Add URLs to API responses

Resolves inability of API consumers to provide links to OSEM.
This commit is contained in:
Andrew Kvalheim 2022-10-27 12:57:42 -07:00
parent 5b89f64eaf
commit e01fd2d721
6 changed files with 27 additions and 3 deletions

View file

@ -2,7 +2,9 @@
class ConferenceSerializer < ActiveModel::Serializer
include ApplicationHelper
attributes :short_title, :title, :description, :start_date, :end_date, :picture_url,
include Rails.application.routes.url_helpers
attributes :short_title, :url, :title, :description, :start_date, :end_date, :picture_url,
:difficulty_levels, :event_types, :rooms, :tracks,
:date_range, :revision
@ -56,6 +58,10 @@ class ConferenceSerializer < ActiveModel::Serializer
end
end
def url
url_for(object)
end
def revision
object.revision || 0
end

View file

@ -2,8 +2,13 @@
class EventSerializer < ActiveModel::Serializer
include ActionView::Helpers::TextHelper
include Rails.application.routes.url_helpers
attributes :guid, :title, :length, :scheduled_date, :language, :abstract, :speaker_ids, :type, :room, :track
attributes :guid, :url, :title, :length, :scheduled_date, :language, :abstract, :speaker_ids, :type, :room, :track
def url
conference_program_proposal_url(object.conference.short_title, object.id)
end
def scheduled_date
t = object.time

View file

@ -2,8 +2,13 @@
class SpeakerSerializer < ActiveModel::Serializer
include ActionView::Helpers::TextHelper
include Rails.application.routes.url_helpers
attributes :name, :affiliation, :biography
attributes :url, :name, :affiliation, :biography
delegate :name, to: :object
def url
url_for(object)
end
end