Merge pull request #3096 from AndrewKvalheim/api-urls

Add URLs to API responses
This commit is contained in:
Henne Vogelsang 2023-04-19 13:26:44 +02:00 committed by GitHub
commit 04b45adbe5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 48 additions and 8 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