VRFS-1682, VRFS-1679 : upload music notation, download music notation
This commit is contained in:
parent
5685e2f0e8
commit
fbeddf1735
|
|
@ -30,6 +30,10 @@ module JamRuby
|
||||||
s3_manager.sign_url(self[:file_url], {:expires => expiration_time, :secure => false})
|
s3_manager.sign_url(self[:file_url], {:expires => expiration_time, :secure => false})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def filename
|
||||||
|
File.basename(self.file_url)
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def delete_s3_files
|
def delete_s3_files
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,29 @@ module JamRuby
|
||||||
tracks
|
tracks
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def can_join? user, as_musician
|
||||||
|
if as_musician
|
||||||
|
unless user.musician
|
||||||
|
return false # "a fan can not join a music session as a musician"
|
||||||
|
end
|
||||||
|
|
||||||
|
if self.musician_access
|
||||||
|
if self.approval_required
|
||||||
|
return self.invited_musicians.exists?(user)
|
||||||
|
else
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
else
|
||||||
|
# the creator can always join, and the invited users can join
|
||||||
|
return self.creator == user || self.invited_musicians.exists?(user)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
# it's a fan, and the only way a fan can join is if fan_access is true
|
||||||
|
self.fan_access
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def self.index(current_user, user_id, band_id = nil, genre = nil)
|
def self.index(current_user, user_id, band_id = nil, genre = nil)
|
||||||
hide_private = false
|
hide_private = false
|
||||||
if current_user.id != user_id
|
if current_user.id != user_id
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,37 @@
|
||||||
|
require 'aws-sdk'
|
||||||
|
|
||||||
|
class ApiMusicNotationsController < ApiController
|
||||||
|
before_filter :api_signed_in_user
|
||||||
|
|
||||||
|
respond_to :json
|
||||||
|
|
||||||
|
def create
|
||||||
|
client_id = params[:client_id]
|
||||||
|
|
||||||
|
if client_id.nil?
|
||||||
|
raise JamArgumentError, "client_id must be asdfasfdasdf specified"
|
||||||
|
end
|
||||||
|
|
||||||
|
@music_notation = MusicNotation.new
|
||||||
|
@music_notation.client_id = client_id
|
||||||
|
@music_notation.file_url = params[:file]
|
||||||
|
@music_notation.user = current_user
|
||||||
|
@music_notation.save
|
||||||
|
|
||||||
|
if @music_notation.errors.any?
|
||||||
|
response.status = :unprocessable_entity
|
||||||
|
respond_with @music_notation
|
||||||
|
else
|
||||||
|
respond_with @music_notation, responder: ApiResponder, :statue => 201
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def download
|
||||||
|
@music_notation = MusicNotation.find(params[:id])
|
||||||
|
unless @music_notation.music_session.nil? || @music_notation.music_session.can_join?(current_user, true)
|
||||||
|
raise PermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR
|
||||||
|
end
|
||||||
|
|
||||||
|
redirect_to @music_notation.sign_url
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
object @music_notations
|
||||||
|
|
||||||
|
attribute :id
|
||||||
|
|
@ -49,6 +49,13 @@ else
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
child(:music_notations => :music_notations) {
|
||||||
|
node do |music_notation|
|
||||||
|
attributes :id
|
||||||
|
note(:filename) { |music_notation| music_notation.filename }
|
||||||
|
end
|
||||||
|
}
|
||||||
|
|
||||||
child(:active_music_session => :active_music_session) {
|
child(:active_music_session => :active_music_session) {
|
||||||
attributes :claimed_recording_initiator_id, :track_changes_counter
|
attributes :claimed_recording_initiator_id, :track_changes_counter
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -170,6 +170,10 @@ SampleApp::Application.routes.draw do
|
||||||
match '/sessions/:id/tracks/:track_id' => 'api_music_sessions#track_show', :via => :get, :as => 'api_session_track_detail'
|
match '/sessions/:id/tracks/:track_id' => 'api_music_sessions#track_show', :via => :get, :as => 'api_session_track_detail'
|
||||||
match '/sessions/:id/tracks/:track_id' => 'api_music_sessions#track_destroy', :via => :delete
|
match '/sessions/:id/tracks/:track_id' => 'api_music_sessions#track_destroy', :via => :delete
|
||||||
|
|
||||||
|
# Music notations
|
||||||
|
match '/music_notations' => 'api_music_notations#create', :via => :post
|
||||||
|
match '/music_notations/:id' => 'api_music_notations#download', :via => :get, :as => :download_music_notation
|
||||||
|
|
||||||
# RSVP requests
|
# RSVP requests
|
||||||
match '/rsvp_requests' => 'api_rsvp_requests#index', :via => :get
|
match '/rsvp_requests' => 'api_rsvp_requests#index', :via => :get
|
||||||
match '/rsvp_requests' => 'api_rsvp_requests#create', :via => :post
|
match '/rsvp_requests' => 'api_rsvp_requests#create', :via => :post
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue