* VRFS-2876 cleaning up preview downloadability in jam-admin
This commit is contained in:
parent
9279d88d8d
commit
6c82e00d00
|
|
@ -22,29 +22,19 @@ ActiveAdmin.register JamRuby::JamTrack, :as => 'JamTracks' do
|
|||
links
|
||||
end
|
||||
|
||||
|
||||
column :id
|
||||
column :name
|
||||
column :description
|
||||
column :version
|
||||
column :time_signature
|
||||
column :status
|
||||
column :recording_type
|
||||
column :original_artist
|
||||
column :songwriter
|
||||
column :publisher
|
||||
column :name
|
||||
column :status
|
||||
column :preview do |jam_track| jam_track.has_preview? ? (link_to "Download", jam_track.sign_url(3600)) : 'None' end
|
||||
column :master_track do |jam_track| jam_track.master_track.nil? ? 'None' : (link_to "Download", jam_track.master_track.url_by_sample_rate(44)) end
|
||||
column :licensor
|
||||
column :pro
|
||||
column :genre
|
||||
column :sales_region
|
||||
column :price
|
||||
column :reproduction_royalty
|
||||
column :public_performance_royalty
|
||||
column :reproduction_royalty_amount
|
||||
column :licensor_royalty_amount
|
||||
column :pro_royalty_amount
|
||||
column :url
|
||||
column :created_at
|
||||
column :id
|
||||
|
||||
column :jam_track_tracks do |jam_track|
|
||||
table_for jam_track.jam_track_tracks.order('position ASC') do
|
||||
|
|
|
|||
|
|
@ -24,6 +24,10 @@
|
|||
= f.input :reproduction_royalty_amount, :required=>true, :input_html=>{type:'numeric'}
|
||||
= f.input :licensor_royalty_amount, :required=>true, :input_html=>{type:'numeric'}
|
||||
= f.input :preview_start_time_raw, :label=>'Preview Start Time', :hint => 'MM:SS:MLS', :as => :string
|
||||
- unless f.object.nil? || f.object[:preview_url].nil?
|
||||
.current_file_holder style='margin-bottom:10px'
|
||||
a href=f.object.sign_url(3600) style='padding:0 0 0 20px'
|
||||
| Download
|
||||
|
||||
//= f.input :url, :as => :file, :label => 'Audio File'
|
||||
= f.input :jmep_text, :as => :text, :label => "JMEP Text", :input_html => {:rows => 5 }, :hint => 'Tap-Ins & Lead Silence. Examples: https://jamkazam.atlassian.net/wiki/pages/viewpage.action?pageId=39289025#JamKazamMeta-EventProcessor(JMEP)-CommonExamples'
|
||||
|
|
|
|||
|
|
@ -12,8 +12,6 @@ module JamRuby
|
|||
|
||||
@@log = Logging.logger[JamTrack]
|
||||
|
||||
mount_uploader :preview_url, JamTrackUploader
|
||||
|
||||
attr_accessor :uploading_preview
|
||||
attr_accessible :name, :description, :bpm, :time_signature, :status, :recording_type,
|
||||
:original_artist, :songwriter, :publisher, :licensor, :licensor_id, :pro, :genre, :genre_id, :sales_region, :price,
|
||||
|
|
@ -99,6 +97,9 @@ module JamRuby
|
|||
"jam_track_previews/#{self.original_artist}/#{self.name}/preview-44100.ogg"
|
||||
end
|
||||
|
||||
def has_preview?
|
||||
!self["preview_url"].nil?
|
||||
end
|
||||
# creates a short-lived URL that has access to the object.
|
||||
# the idea is that this is used when a user who has the rights to this tries to download this JamTrack
|
||||
# we would verify their rights (can_download?), and generates a URL in response to the click so that they can download
|
||||
|
|
|
|||
|
|
@ -117,44 +117,5 @@ describe JamTrack do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "upload/download" do
|
||||
PREVIEW_NAME = 'blah.ogg'
|
||||
|
||||
in_directory_with_file(PREVIEW_NAME)
|
||||
|
||||
before(:all) do
|
||||
original_storage = JamTrackUploader.storage = :fog
|
||||
end
|
||||
|
||||
after(:all) do
|
||||
JamTrackUploader.storage = @original_storage
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
content_for_file('abc')
|
||||
end
|
||||
|
||||
it "uploads to s3 with correct name, and then downloads via signed URL" do
|
||||
jam_track = FactoryGirl.create(:jam_track)
|
||||
uploader = JamTrackUploader.new(jam_track, :preview_url)
|
||||
uploader.store!(File.open(PREVIEW_NAME)) # uploads file
|
||||
jam_track.save!
|
||||
|
||||
# verify that the uploader stores the correct path
|
||||
jam_track[:preview_url].should == jam_track.preview_filename
|
||||
|
||||
# verify it's on S3
|
||||
s3 = S3Manager.new(APP_CONFIG.aws_bucket, APP_CONFIG.aws_access_key_id, APP_CONFIG.aws_secret_access_key)
|
||||
s3.exists?(jam_track[:preview_url]).should be_true
|
||||
s3.length(jam_track[:preview_url]).should == 'abc'.length
|
||||
|
||||
# download it via signed URL, and check contents
|
||||
url = jam_track.sign_url
|
||||
downloaded_contents = open(url).read
|
||||
downloaded_contents.should == 'abc'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue