mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #3096 from AndrewKvalheim/api-urls
Add URLs to API responses
This commit is contained in:
commit
04b45adbe5
10 changed files with 48 additions and 8 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue