jam-cloud/web/app/views/api_recordings/show.rabl

62 lines
1.5 KiB
Ruby

object @recording
attributes :id, :band, :created_at, :duration, :comment_count, :like_count, :play_count
node :mix do |recording|
if recording.mix
{
id: recording.mix.id
}
else
nil
end
end
child(:band => :band) {
attributes :id, :name, :location, :photo_url
}
child(:owner => :owner) {
attributes :id, :name, :location, :photo_url
}
child(:recorded_tracks => :recorded_tracks) {
node do |recorded_track|
partial("api_recordings/show_recorded_track", :object => recorded_track)
end
}
child(:comments => :comments) {
attributes :comment, :created_at
child(:user => :creator) {
attributes :id, :first_name, :last_name, :photo_url
}
}
# returns the current_user's version of the recording, i.e., their associated claimed_recording if present
node :my do |recording|
claim = recording.claim_for_user(current_user) || recording.candidate_claimed_recording
if claim
{ name: claim.name, description: claim.description, genre: claim.genre.id, genre_name: claim.genre.description }
else
nil
end
end
child(:claimed_recordings => :claimed_recordings) {
attributes :id, :name, :description, :is_public, :genre_id, :has_mix?, :user_id
node :share_url do |claimed_recording|
unless claimed_recording.share_token.nil?
share_token_url(claimed_recording.share_token.token)
end
end
node :mix do |claimed_recording|
listen_mix_url(claimed_recording.recording) if claimed_recording.has_mix?
end
}