From 9279d88d8d866c03d628b3a8742a504296d1ba69 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Tue, 10 Mar 2015 22:10:22 -0500 Subject: [PATCH 1/5] * VRFS-2876 - pro licensing added and 20 second snippet --- .../views/admin/jam_tracks/_form.html.slim | 13 ++- admin/config/initializers/jam_tracks.rb | 99 +++++++++++++++++++ db/manifest | 3 +- db/up/jam_track_pro_licensing_update.sql | 12 +++ .../app/uploaders/jam_track_uploader.rb | 4 +- ruby/lib/jam_ruby/jam_track_importer.rb | 1 - ruby/lib/jam_ruby/models/jam_track.rb | 77 +++------------ ruby/lib/jam_ruby/models/jam_track_tap_in.rb | 1 - ruby/spec/factories.rb | 2 - ruby/spec/jam_ruby/jam_track_importer_spec.rb | 1 - .../jam_ruby/models/jam_track_right_spec.rb | 8 -- ruby/spec/jam_ruby/models/jam_track_spec.rb | 14 +-- .../controllers/api_jam_tracks_controller.rb | 9 -- web/config/routes.rb | 1 - web/spec/factories.rb | 2 - 15 files changed, 146 insertions(+), 101 deletions(-) create mode 100644 db/up/jam_track_pro_licensing_update.sql diff --git a/admin/app/views/admin/jam_tracks/_form.html.slim b/admin/app/views/admin/jam_tracks/_form.html.slim index 2eb08fd27..a95275b82 100644 --- a/admin/app/views/admin/jam_tracks/_form.html.slim +++ b/admin/app/views/admin/jam_tracks/_form.html.slim @@ -6,22 +6,25 @@ = f.input :plan_code, :label=>'Recurly Plan Code', :required=>true, :hint => 'Must match plan code in Recurly' = f.input :version, :label => 'Version', :hint => 'Increment this value whenever you invalidate (update) the media in the JamTrack. Changing JMEP does not count as a version change; changing anything about a track (audio, instrument, part) does.' //= f.input :initial_play_silence, :label => 'Initial Play Silence (seconds)' - = f.input :time_signature, collection: JamRuby::JamTrack::TIME_SIGNATURES, include_blank: false + = f.input :time_signature, collection: JamRuby::JamTrack::TIME_SIGNATURES, include_blank: true = f.input :status, collection: JamRuby::JamTrack::STATUS, include_blank: false, hint: 'Only set to Production when end users should be able to purchase this JamTrack' = f.input :recording_type, collection: JamRuby::JamTrack::RECORDING_TYPE, include_blank: false = f.input :original_artist, :input_html => { :rows=>1, :maxlength=>1000 } = f.input :songwriter, :input_html => { :rows=>1, :maxlength=>1000 } = f.input :publisher, :input_html => { :rows=>1, :maxlength=>1000 } - = f.input :licensor, collection: JamRuby::JamTrackLicensor.all, include_blank: false - = f.input :pro, collection: JamRuby::JamTrack::PRO, include_blank: false + = f.input :licensor, collection: JamRuby::JamTrackLicensor.all, include_blank: true = f.input :genre, collection: JamRuby::Genre.all, include_blank: false = f.input :sales_region, collection: JamRuby::JamTrack::SALES_REGION, include_blank: false - = f.input :price, :required=>true, :input_html=>{type:'numeric'} + = f.input :price, :required => true, :input_html => {type: 'numeric'} + = f.input :pro_ascap, :label => 'ASCAP royalties due?' + = f.input :pro_bmi, :label => 'BMI royalties due?' + = f.input :pro_sesac, :label => 'SESAC royalties due?' = f.input :reproduction_royalty, :label => 'Reproduction Royalty' = f.input :public_performance_royalty, :label => 'Public Performance Royalty' = f.input :reproduction_royalty_amount, :required=>true, :input_html=>{type:'numeric'} = f.input :licensor_royalty_amount, :required=>true, :input_html=>{type:'numeric'} - = f.input :pro_royalty_amount, :required=>true, :input_html=>{type:'numeric'} + = f.input :preview_start_time_raw, :label=>'Preview Start Time', :hint => 'MM:SS:MLS', :as => :string + //= 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' = f.input :jmep_json, :as => :text, :label => "JMEP Json", :input_html => {:rows => 5, :readonly => true }, :hint => 'Readonly field. This is shown here just so you can see what your JMEP got converted to readily' diff --git a/admin/config/initializers/jam_tracks.rb b/admin/config/initializers/jam_tracks.rb index c88fc6a2c..c1c0063bf 100644 --- a/admin/config/initializers/jam_tracks.rb +++ b/admin/config/initializers/jam_tracks.rb @@ -2,8 +2,11 @@ class JamRuby::JamTrack # add a custom validation + attr_accessor :preview_generate_error + before_save :jmep_json_generate validate :jmep_text_validate + validate :preview def jmep_text_validate begin @@ -14,6 +17,11 @@ class JamRuby::JamTrack end def jmep_json_generate + self.genre_id = nil if self.genre_id == '' + self.licensor_id = nil if self.licensor_id == '' + self.jmep_json = nil if self.jmep_json == '' + self.time_signature = nil if self.time_signature == '' + begin self[:jmep_json] = JmepManager.execute(self.jmep_text) rescue ArgumentError => err @@ -21,5 +29,96 @@ class JamRuby::JamTrack end end + def preview + if preview_generate_error + errors.add(:preview_url, preview_generate_error) + end + end + + + + # this is used by active admin/jam-admin + def preview_start_time_raw + if self.preview_start_time.nil? || self.preview_start_time.nil? + '' + else + seconds = self.preview_start_time.to_f/1000 + time = Time.at(seconds) + time.strftime("%M:%S:#{(self.preview_start_time % 1000).to_s.rjust(3, '0')}") + end + end + + # this is used by active admin/jam-admin + def preview_start_time_raw=(new_value) + + value = nil + if new_value == nil || new_value == '' + value = nil + else + if new_value && new_value.kind_of?(String) && new_value.include?(':') + bits = new_value.split(':') + if bits.length != 3 + raise "format of preview start time must be MM:SS:MLS" + end + + value = (bits[0].to_i * 60000) + (bits[1].to_i * 1000) + (bits[2].to_i) + + else + raise "format of preview start time must be MM:SS:MLS" + end + end + + if !value.nil? && value != self.preview_start_time + self.preview_start_time = value + generate_preview + else + self.preview_start_time = value + end + end + + def generate_preview + + begin + Dir.mktmpdir do |tmp_dir| + + input = File.join(tmp_dir, 'in.ogg') + output = File.join(tmp_dir, 'out.ogg') + + start = self.preview_start_time.to_f / 1000 + stop = start + 20 + + master_track = self.master_track + + raise 'no master track' unless master_track + + s3_manager.download(master_track.url_by_sample_rate(44), input) + + command = "sox \"#{input}\" \"#{output}\" trim #{start} #{stop}" + + @@log.debug("trimming using: " + command) + + sox_output = `#{command}` + + result_code = $?.to_i + + if result_code != 0 + @preview_generate_error = "unable to execute cut command #{sox_output}" + else + @@log.debug("uploading preview to #{self.preview_filename}") + + s3_manager.upload(self.preview_filename, output) + + # and finally update the JamTrackTrack with the new info + self["preview_url"] = self.preview_filename + self["preview_md5"] = ::Digest::MD5.file(output).hexdigest + self["preview_length"] = File.new(output).size + self.save! + end + end + rescue Exception => e + @preview_generate_error = e.to_s + end + + end end diff --git a/db/manifest b/db/manifest index f744571eb..6d9f1f63d 100755 --- a/db/manifest +++ b/db/manifest @@ -258,4 +258,5 @@ jam_track_version.sql recorded_jam_track_tracks.sql jam_track_jmep_data.sql add_jam_track_bitrates.sql -jam_track_importer.sql \ No newline at end of file +jam_track_importer.sql +jam_track_pro_licensing_update.sql \ No newline at end of file diff --git a/db/up/jam_track_pro_licensing_update.sql b/db/up/jam_track_pro_licensing_update.sql new file mode 100644 index 000000000..006483f44 --- /dev/null +++ b/db/up/jam_track_pro_licensing_update.sql @@ -0,0 +1,12 @@ +ALTER TABLE jam_tracks ADD COLUMN pro_ascap BOOLEAN DEFAULT FALSE NOT NULL; +ALTER TABLE jam_tracks ADD COLUMN pro_bmi BOOLEAN DEFAULT FALSE NOT NULL; +ALTER TABLE jam_tracks ADD COLUMN pro_sesac BOOLEAN DEFAULT FALSE NOT NULL; +UPDATE jam_tracks SET pro_ascap = TRUE WHERE pro = 'ASCAP'; +UPDATE jam_tracks SET pro_bmi = TRUE WHERE pro = 'BMI'; +UPDATE jam_tracks SET pro_sesac = TRUE WHERE pro = 'SESAC'; +ALTER TABLE jam_tracks DROP COLUMN pro; +ALTER TABLE jam_tracks DROP Column pro_royalty_amount; +ALTER TABLE jam_tracks ADD COLUMN preview_start_time INTEGER; +ALTER TABLE jam_tracks RENAME COLUMN url TO preview_url; +ALTER TABLE jam_tracks RENAME COLUMN md5 TO preview_md5; +ALTER TABLE jam_tracks RENAME COLUMN length TO preview_length; diff --git a/ruby/lib/jam_ruby/app/uploaders/jam_track_uploader.rb b/ruby/lib/jam_ruby/app/uploaders/jam_track_uploader.rb index 98e555e3d..9ec9a97ec 100644 --- a/ruby/lib/jam_ruby/app/uploaders/jam_track_uploader.rb +++ b/ruby/lib/jam_ruby/app/uploaders/jam_track_uploader.rb @@ -11,7 +11,7 @@ class JamTrackUploader < CarrierWave::Uploader::Base # Add a white list of extensions which are allowed to be uploaded. def extension_white_list - %w(jkz) + %w(ogg) end def store_dir @@ -23,6 +23,6 @@ class JamTrackUploader < CarrierWave::Uploader::Base end def filename - "#{model.store_dir}/#{model.filename}" if model.id + "#{model.preview_filename}" if model.id && model.uploading_preview end end diff --git a/ruby/lib/jam_ruby/jam_track_importer.rb b/ruby/lib/jam_ruby/jam_track_importer.rb index 39da44bb0..8874a66fe 100644 --- a/ruby/lib/jam_ruby/jam_track_importer.rb +++ b/ruby/lib/jam_ruby/jam_track_importer.rb @@ -102,7 +102,6 @@ module JamRuby jam_track.price = 1.99 jam_track.reproduction_royalty_amount = 0 jam_track.licensor_royalty_amount = 0 - jam_track.pro_royalty_amount = 0 jam_track.sales_region = 'United States' jam_track.recording_type = 'Cover' jam_track.description = "This is a JamTrack audio file for use exclusively with the JamKazam service. This JamTrack is a high quality cover of the #{jam_track.original_artist} song \"#{jam_track.name}\"." diff --git a/ruby/lib/jam_ruby/models/jam_track.rb b/ruby/lib/jam_ruby/models/jam_track.rb index 73e1634c3..9660f7a4f 100644 --- a/ruby/lib/jam_ruby/models/jam_track.rb +++ b/ruby/lib/jam_ruby/models/jam_track.rb @@ -12,35 +12,37 @@ module JamRuby @@log = Logging.logger[JamTrack] - mount_uploader :url, JamTrackUploader + 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, :reproduction_royalty, :public_performance_royalty, :reproduction_royalty_amount, :licensor_royalty_amount, :pro_royalty_amount, :plan_code, :initial_play_silence, :jam_track_tracks_attributes, - :jam_track_tap_ins_attributes, :version, :jmep_json, :jmep_text, as: :admin + :jam_track_tap_ins_attributes, :version, :jmep_json, :jmep_text, :pro_ascap, :pro_bmi, :pro_sesac, :preview_start_time_raw, as: :admin validates :name, presence: true, uniqueness: true, length: {maximum: 200} validates :plan_code, presence: true, uniqueness: true, length: {maximum: 50 } validates :description, length: {maximum: 1000} - validates :time_signature, inclusion: {in: [nil] + TIME_SIGNATURES} + validates :time_signature, inclusion: {in: [nil] + [''] + TIME_SIGNATURES} # the empty string is needed because of activeadmin validates :status, inclusion: {in: [nil] + STATUS} validates :recording_type, inclusion: {in: [nil] + RECORDING_TYPE} validates :original_artist, length: {maximum: 200} validates :songwriter, length: {maximum: 1000} validates :publisher, length: {maximum: 1000} - validates :pro, inclusion: {in: [nil] + PRO} validates :sales_region, inclusion: {in: [nil] + SALES_REGION} validates_format_of :price, with: /^\d+\.*\d{0,2}$/ validates :version, presence: true - + validates :preview_start_time, numericality: {only_integer: true}, length: {in: 1..1000}, :allow_nil => true + validates :pro_ascap, inclusion: {in: [true, false]} + validates :pro_bmi, inclusion: {in: [true, false]} + validates :pro_sesac, inclusion: {in: [true, false]} + validates :public_performance_royalty, inclusion: {in: [nil, true, false]} validates :reproduction_royalty, inclusion: {in: [nil, true, false]} validates :public_performance_royalty, inclusion: {in: [nil, true, false]} + validates_format_of :reproduction_royalty_amount, with: /^\d+\.*\d{0,3}$/ validates_format_of :licensor_royalty_amount, with: /^\d+\.*\d{0,3}$/ - validates_format_of :pro_royalty_amount, with: /^\d+\.*\d{0,3}$/ - - before_save :sanitize_active_admin belongs_to :genre, class_name: "JamRuby::Genre" belongs_to :licensor , class_name: 'JamRuby::JamTrackLicensor', foreign_key: 'licensor_id' @@ -91,15 +93,10 @@ module JamRuby end end end - - # create storage directory that will house this jam_track, as well as - def store_dir - "jam_tracks/#{id}" - end # create name of the file - def filename - "#{name}.jkz" + def preview_filename + "jam_track_previews/#{self.original_artist}/#{self.name}/preview-44100.ogg" end # creates a short-lived URL that has access to the object. @@ -107,9 +104,12 @@ module JamRuby # we would verify their rights (can_download?), and generates a URL in response to the click so that they can download # but the url is short lived enough so that it wouldn't be easily shared def sign_url(expiration_time = 120) - s3_manager.sign_url(self[:url], {:expires => expiration_time, :response_content_type => 'audio/jkz', :secure => false}) + s3_manager.sign_url(self[:preview_url], {:expires => expiration_time, :response_content_type => 'audio/ogg', :secure => false}) end + def master_track + JamTrackTrack.where(jam_track_id: self.id).where(track_type: 'Master').first + end def can_download?(user) owners.include?(user) @@ -118,50 +118,5 @@ module JamRuby def right_for_user(user) jam_track_rights.where("user_id=?", user).first end - - def self.list_downloads(user, limit = 100, since = 0, bitrate = 48) - since = 0 unless since || since == '' # guard against nil - downloads = [] - - user.jam_track_rights - .limit(limit) - .where('jam_track_rights.id > ?', since) - .each do |jam_track_right| - download = { - :type => "jam_track", - :id => jam_track_right.id.to_s, - :jam_track_id => jam_track_right.jam_track_id, - :created_at => jam_track_right.created_at, - :next => jam_track_right.id - } - if(bitrate==48) - download[:length] = jam_track_right.length_48 - download[:md5] = jam_track_right.md5_48 - download[:url] = jam_track_right.url_48 - else - download[:length] = jam_track_right.length_44 - download[:md5] = jam_track_right.md5_44 - download[:url] = jam_track_right.url_44 - end - downloads << download - end - - next_id = downloads[-1][:next] if downloads.length > 0 - next_id = since if next_id.nil? # echo back to the client the same value they passed in, if there are no results - - { - 'downloads' => downloads, - 'next' => next_id.to_s - } - end - - - private - - def sanitize_active_admin - self.genre_id = nil if self.genre_id == '' - self.licensor_id = nil if self.licensor_id == '' - self.jmep_json = nil if self.jmep_json = '' - end end end diff --git a/ruby/lib/jam_ruby/models/jam_track_tap_in.rb b/ruby/lib/jam_ruby/models/jam_track_tap_in.rb index 0bddeb8c6..fa0e63eda 100644 --- a/ruby/lib/jam_ruby/models/jam_track_tap_in.rb +++ b/ruby/lib/jam_ruby/models/jam_track_tap_in.rb @@ -35,7 +35,6 @@ module JamRuby else raise "format of offset time must be MM:SS:MLS" end - end end end \ No newline at end of file diff --git a/ruby/spec/factories.rb b/ruby/spec/factories.rb index 322b206bd..18dbeb8bf 100644 --- a/ruby/spec/factories.rb +++ b/ruby/spec/factories.rb @@ -730,14 +730,12 @@ FactoryGirl.define do sequence(:original_artist) { |n| "original-artist-#{n}" } sequence(:songwriter) { |n| "songwriter-#{n}" } sequence(:publisher) { |n| "publisher-#{n}" } - pro 'ASCAP' sales_region 'United States' price 1.99 reproduction_royalty true public_performance_royalty true reproduction_royalty_amount 0.999 licensor_royalty_amount 0.999 - pro_royalty_amount 0.999 sequence(:plan_code) { |n| "jamtrack-#{n}" } genre JamRuby::Genre.first diff --git a/ruby/spec/jam_ruby/jam_track_importer_spec.rb b/ruby/spec/jam_ruby/jam_track_importer_spec.rb index eda890d1f..5a0a89cf4 100644 --- a/ruby/spec/jam_ruby/jam_track_importer_spec.rb +++ b/ruby/spec/jam_ruby/jam_track_importer_spec.rb @@ -57,7 +57,6 @@ describe JamTrackImporter do jam_track.original_artist.should eq('Artist 1') jam_track.songwriter.should be_nil jam_track.publisher.should be_nil - jam_track.pro.should be_nil jam_track.sales_region.should eq('United States') jam_track.price.should eq(1.99) end diff --git a/ruby/spec/jam_ruby/models/jam_track_right_spec.rb b/ruby/spec/jam_ruby/models/jam_track_right_spec.rb index ee7497f40..bd8e48196 100644 --- a/ruby/spec/jam_ruby/models/jam_track_right_spec.rb +++ b/ruby/spec/jam_ruby/models/jam_track_right_spec.rb @@ -17,14 +17,6 @@ describe JamTrackRight do end - it "lists" do - jam_track_right = FactoryGirl.create(:jam_track_right) - jam_tracks = JamTrack.list_downloads(jam_track_right.user) - jam_tracks.should have_key('downloads') - jam_tracks.should have_key('next') - jam_tracks['downloads'].should have(1).items - end - describe "validations" do it "one purchase per user/jam_track combo" do user = FactoryGirl.create(:user) diff --git a/ruby/spec/jam_ruby/models/jam_track_spec.rb b/ruby/spec/jam_ruby/models/jam_track_spec.rb index af4980f7b..0f41e5f25 100644 --- a/ruby/spec/jam_ruby/models/jam_track_spec.rb +++ b/ruby/spec/jam_ruby/models/jam_track_spec.rb @@ -119,9 +119,9 @@ describe JamTrack do end describe "upload/download" do - JKA_NAME = 'blah.jkz' + PREVIEW_NAME = 'blah.ogg' - in_directory_with_file(JKA_NAME) + in_directory_with_file(PREVIEW_NAME) before(:all) do original_storage = JamTrackUploader.storage = :fog @@ -137,17 +137,17 @@ describe JamTrack do 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, :url) - uploader.store!(File.open(JKA_NAME)) # uploads file + 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[:url].should == jam_track.store_dir + '/' + jam_track.filename + 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[:url]).should be_true - s3.length(jam_track[:url]).should == 'abc'.length + 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 diff --git a/web/app/controllers/api_jam_tracks_controller.rb b/web/app/controllers/api_jam_tracks_controller.rb index b2322c4a5..eff17afa0 100644 --- a/web/app/controllers/api_jam_tracks_controller.rb +++ b/web/app/controllers/api_jam_tracks_controller.rb @@ -23,15 +23,6 @@ class ApiJamTracksController < ApiController render "api_jam_tracks/purchased", :layout => nil end - def downloads - sample_rate = params[:sample_rate].nil? ? nil : params[:sample_rate].to_i - begin - render :json => JamTrack.list_downloads(current_user, params[:limit], params[:since], sample_rate), :status => 200 - rescue - render :json => { :message => "could not produce list of files" }, :status => 403 - end - end - def download if @jam_track_right.valid? sample_rate = params[:sample_rate].nil? ? nil : params[:sample_rate].to_i diff --git a/web/config/routes.rb b/web/config/routes.rb index 00fd25f38..d21ed3861 100644 --- a/web/config/routes.rb +++ b/web/config/routes.rb @@ -206,7 +206,6 @@ SampleApp::Application.routes.draw do # Jamtracks match '/jamtracks' => 'api_jam_tracks#index', :via => :get, :as => 'api_jam_tracks_list' match '/jamtracks/purchased' => 'api_jam_tracks#purchased', :via => :get, :as => 'api_jam_tracks_purchased' - match '/jamtracks/downloads' => 'api_jam_tracks#downloads', :via => :get, :as => 'api_jam_tracks_downloads' match '/jamtracks/download/:id' => 'api_jam_tracks#download', :via => :get, :as => 'api_jam_tracks_download' match '/jamtracks/enqueue/:id' => 'api_jam_tracks#enqueue', :via => :post, :as => 'api_jam_tracks_enqueue' match '/jamtracks/rights/:id' => 'api_jam_tracks#show_jam_track_right', :via => :get, :as => 'api_jam_tracks_show_right' diff --git a/web/spec/factories.rb b/web/spec/factories.rb index 1912f434d..59a8089fa 100644 --- a/web/spec/factories.rb +++ b/web/spec/factories.rb @@ -717,14 +717,12 @@ FactoryGirl.define do sequence(:original_artist) { |n| "original-artist-#{n}" } sequence(:songwriter) { |n| "songwriter-#{n}" } sequence(:publisher) { |n| "publisher-#{n}" } - pro 'ASCAP' sales_region 'United States' price 1.99 reproduction_royalty true public_performance_royalty true reproduction_royalty_amount 0.999 licensor_royalty_amount 0.999 - pro_royalty_amount 0.999 sequence(:plan_code) { |n| "jamtrack-#{n}" } ignore do make_track true From 6c82e00d0036209c99c368dd6c887ff8e53c79e4 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 11 Mar 2015 09:20:45 -0500 Subject: [PATCH 2/5] * VRFS-2876 cleaning up preview downloadability in jam-admin --- admin/app/admin/jam_tracks.rb | 20 +++------- .../views/admin/jam_tracks/_form.html.slim | 4 ++ ruby/lib/jam_ruby/models/jam_track.rb | 5 ++- ruby/spec/jam_ruby/models/jam_track_spec.rb | 39 ------------------- 4 files changed, 12 insertions(+), 56 deletions(-) diff --git a/admin/app/admin/jam_tracks.rb b/admin/app/admin/jam_tracks.rb index 67d961f22..ac1897c4e 100644 --- a/admin/app/admin/jam_tracks.rb +++ b/admin/app/admin/jam_tracks.rb @@ -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 diff --git a/admin/app/views/admin/jam_tracks/_form.html.slim b/admin/app/views/admin/jam_tracks/_form.html.slim index a95275b82..b74dba9c1 100644 --- a/admin/app/views/admin/jam_tracks/_form.html.slim +++ b/admin/app/views/admin/jam_tracks/_form.html.slim @@ -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' diff --git a/ruby/lib/jam_ruby/models/jam_track.rb b/ruby/lib/jam_ruby/models/jam_track.rb index 9660f7a4f..47efe3cdf 100644 --- a/ruby/lib/jam_ruby/models/jam_track.rb +++ b/ruby/lib/jam_ruby/models/jam_track.rb @@ -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 diff --git a/ruby/spec/jam_ruby/models/jam_track_spec.rb b/ruby/spec/jam_ruby/models/jam_track_spec.rb index 0f41e5f25..063f3a029 100644 --- a/ruby/spec/jam_ruby/models/jam_track_spec.rb +++ b/ruby/spec/jam_ruby/models/jam_track_spec.rb @@ -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 From 0a869e91e3abd2aa6d2b90dc8000281465e59309 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 11 Mar 2015 16:44:22 -0500 Subject: [PATCH 3/5] * VRFS-2913 - allow /client to be accessed without being logged in --- web/app/assets/javascripts/accounts.js | 6 ++- .../javascripts/dialog/loginRequiredDialog.js | 45 +++++++++++++++++++ .../javascripts/everywhere/everywhere.js | 3 ++ web/app/assets/javascripts/findSession.js | 2 + web/app/assets/javascripts/homeScreen.js | 14 +++++- .../javascripts/jam_track_utils.js.coffee | 2 +- web/app/assets/javascripts/jamkazam.js | 32 +++++++++++-- web/app/assets/javascripts/layout.js | 18 +++++++- .../assets/javascripts/notificationPanel.js | 6 ++- .../javascripts/scheduled_session.js.erb | 2 +- web/app/assets/javascripts/sidebar.js | 28 +++++++++--- .../assets/stylesheets/client/home.css.scss | 4 ++ .../stylesheets/client/sidebar.css.scss | 4 ++ .../dialogs/loginRequiredDialog.css.scss | 12 +++++ web/app/controllers/api_genres_controller.rb | 3 -- .../controllers/api_instruments_controller.rb | 3 -- web/app/helpers/sessions_helper.rb | 4 ++ web/app/views/clients/_header.html.erb | 4 +- web/app/views/clients/_home.html.slim | 30 ++++++------- web/app/views/clients/_jamtrack.html.haml | 2 +- web/app/views/clients/index.html.erb | 28 +++++------- web/app/views/dialogs/_dialogs.html.haml | 1 + .../dialogs/_loginRequiredDialog.html.slim | 20 +++++++++ .../api_jam_tracks_controller_spec.rb | 13 ------ .../features/authentication_pages_spec.rb | 3 +- web/spec/features/in_session_spec.rb | 4 +- web/spec/features/profile_menu_spec.rb | 2 +- web/spec/features/signin_spec.rb | 21 ++++++++- web/spec/support/utilities.rb | 7 ++- 29 files changed, 243 insertions(+), 80 deletions(-) create mode 100644 web/app/assets/javascripts/dialog/loginRequiredDialog.js create mode 100644 web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss create mode 100644 web/app/views/dialogs/_loginRequiredDialog.html.slim diff --git a/web/app/assets/javascripts/accounts.js b/web/app/assets/javascripts/accounts.js index 64501695d..90b0c4e5e 100644 --- a/web/app/assets/javascripts/accounts.js +++ b/web/app/assets/javascripts/accounts.js @@ -105,9 +105,11 @@ } function renderAccount() { + app.user().done(function() { rest.getUserDetail() - .done(populateAccount) - .error(app.ajaxError) + .done(populateAccount) + .error(app.ajaxError) + }) } function navToScheduledSessions() { diff --git a/web/app/assets/javascripts/dialog/loginRequiredDialog.js b/web/app/assets/javascripts/dialog/loginRequiredDialog.js new file mode 100644 index 000000000..6795614c1 --- /dev/null +++ b/web/app/assets/javascripts/dialog/loginRequiredDialog.js @@ -0,0 +1,45 @@ +(function(context,$) { + + "use strict"; + context.JK = context.JK || {}; + context.JK.LoginRequiredDialog = function(app) { + var logger = context.JK.logger; + var $dialog = null; + var dialogId = 'login-required-dialog'; + + function beforeShow(data) { + } + + function afterShow(data) { + } + + function afterHide() { + } + + function events() { + $dialog.find('.go-to-jamtracks').click(function() { + app.layout.closeDialog(dialogId) + context.location.href = $(this).attr('href') + }) + } + + function initialize() { + + var dialogBindings = { + 'beforeShow' : beforeShow, + 'afterShow' : afterShow, + 'afterHide': afterHide + }; + + app.bindDialog(dialogId, dialogBindings); + + $dialog = $('#' + dialogId); + + events(); + } + + this.initialize = initialize; + }; + + return this; +})(window,jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/everywhere/everywhere.js b/web/app/assets/javascripts/everywhere/everywhere.js index 4564cd9b0..b8c0f62d5 100644 --- a/web/app/assets/javascripts/everywhere/everywhere.js +++ b/web/app/assets/javascripts/everywhere/everywhere.js @@ -127,6 +127,9 @@ var clientPreferencesDialog = new JK.ClientPreferencesDialog(app); clientPreferencesDialog.initialize(); + + var loginRequiredDialog = new JK.LoginRequiredDialog(app); + loginRequiredDialog.initialize(); } // wait 10 seconds diff --git a/web/app/assets/javascripts/findSession.js b/web/app/assets/javascripts/findSession.js index f54feb866..d3c4638c2 100644 --- a/web/app/assets/javascripts/findSession.js +++ b/web/app/assets/javascripts/findSession.js @@ -57,9 +57,11 @@ }) .fail(function(xhr, textStatus, errorMessage) { if (xhr.status === 404) { + logger.warn("unable to list active sessions (404)") // swallow 404 } else { + logger.warn("unable to list active sessions") app.ajaxError(xhr, textStatus, errorMessage); } }) diff --git a/web/app/assets/javascripts/homeScreen.js b/web/app/assets/javascripts/homeScreen.js index 997927dbd..ec7b86d50 100644 --- a/web/app/assets/javascripts/homeScreen.js +++ b/web/app/assets/javascripts/homeScreen.js @@ -6,6 +6,7 @@ context.JK.HomeScreen = function(app) { var logger = context.JK.logger; var isFtueComplete = false; + var $screen = null; function beforeShow(data) { } @@ -86,9 +87,20 @@ var screenBindings = { 'beforeShow': beforeShow }; app.bindScreen('home', screenBindings); events(); + $screen = $('.screen[layout-id="home"]') - $('.profile').on('click', function() { + $screen.find('.profile').on('click', function() { + var $destination = $('[layout-id="profile"]'); + if(!context.JK.currentUserId && !$destination.is('.no-login-required')) { + // if there is no user and login is required, then stop user from clicknig through + app.layout.showDialog('login-required-dialog') + } + else + { context.location = '/client#/profile/' + context.JK.currentUserId; + } + + }); }; diff --git a/web/app/assets/javascripts/jam_track_utils.js.coffee b/web/app/assets/javascripts/jam_track_utils.js.coffee index 2935665cc..8ba73f592 100644 --- a/web/app/assets/javascripts/jam_track_utils.js.coffee +++ b/web/app/assets/javascripts/jam_track_utils.js.coffee @@ -16,7 +16,7 @@ class JamTrackUtils @rest.getShoppingCarts().done(this.displayCartIcon) displayCartIcon: (carts) => - cartLink = $("a[href='" + "/client#/shoppingCart" + "']") + cartLink = $("#header-shopping-cart") if carts.length > 0 cartLink.removeClass("hidden") else diff --git a/web/app/assets/javascripts/jamkazam.js b/web/app/assets/javascripts/jamkazam.js index db0615510..2bc31b957 100644 --- a/web/app/assets/javascripts/jamkazam.js +++ b/web/app/assets/javascripts/jamkazam.js @@ -132,6 +132,9 @@ logger.error("Unexpected ajax error: " + textStatus + ", msg:" + errorMessage); app.notify({title: "Oops!", text: "What you were looking for is gone now."}); } + else if(jqXHR.status === 403) { + logger.debug("not logged in"); + } else if (jqXHR.status === 422) { logger.error("Unexpected ajax error: " + textStatus + ", msg: " + errorMessage + ", response: " + jqXHR.responseText); // present a nicer message @@ -282,20 +285,37 @@ var hash = context.location.hash; + var screen = 'home' try { - context.RouteMap.parse(hash); + var location = context.RouteMap.parse(hash); + screen = location.page.substring(1); // remove leading slash } catch (e) { logger.debug("ignoring bogus screen name: %o", hash) hash = null; } - var url = '/client#/home'; + + var $destination = $('[layout-id="' + screen + '"]'); + + if(!context.JK.currentUserId && !$destination.is('.no-login-required')) { + logger.debug("not logged in so redirected to login from screen: " + screen) + var redirectPath= '?redirect-to=' + encodeURIComponent(JK.locationPath()); + if(gon.isNativeClient) { + window.location.href = '/signin' + redirectPath; + } + else { + window.location.href = '/' + redirectPath; + } + return; + } + + var url = '/client#/' + screen; if (hash) { url = hash; } - logger.debug("Changing screen to " + url); + logger.debug("jamkazam: Changing screen to " + url + " (hash=" + hash + ")") ; context.location = url; } @@ -377,7 +397,11 @@ app.notify({title: "Unable to Load User", text: "You should reload the page."}) }); } - } // if userDeferred + } + else { + userDeferred = new $.Deferred(); + userDeferred.reject('not_logged_in'); + } $(document).triggerHandler('JAMKAZAM_READY', {app:app}) diff --git a/web/app/assets/javascripts/layout.js b/web/app/assets/javascripts/layout.js index 6c40f596d..1179f71b2 100644 --- a/web/app/assets/javascripts/layout.js +++ b/web/app/assets/javascripts/layout.js @@ -415,8 +415,15 @@ } var destination = $(evt.currentTarget).attr('layout-link'); - var destinationType = $('[layout-id="' + destination + '"]').attr("layout"); + var $destination = $('[layout-id="' + destination + '"]'); + + var destinationType = $destination.attr("layout"); if (destinationType === "screen") { + if(!context.JK.currentUserId && !$destination.is('.no-login-required')) { + // there is no user, and this item does not support 'no-login', so warn user + showDialog('login-required-dialog'); + return; + } context.location = '/client#/' + destination; } else if (destinationType === "dialog") { showDialog(destination); @@ -548,7 +555,7 @@ var accepted = screenEvent(previousScreen, 'beforeHide', data); if(accepted === false) return; - logger.debug("Changing screen to " + currentScreen); + logger.debug("layout: changing screen to " + currentScreen); $(document).triggerHandler(EVENTS.SCREEN_CHANGED, {previousScreen: previousScreen, newScreen: currentScreen}) @@ -695,6 +702,7 @@ return null; } logger.debug("opening dialog: " + dialog) + var $overlay = $('.dialog-overlay') if (opts.sizeOverlayToContent) { @@ -727,6 +735,12 @@ function panelHeaderClicked(evt) { evt.preventDefault(); + + if(!context.JK.currentUserId) { + showDialog('login-required-dialog'); + return false; + } + expandedPanel = $(evt.currentTarget).closest('[layout="panel"]').attr("layout-id"); layout(); return false; diff --git a/web/app/assets/javascripts/notificationPanel.js b/web/app/assets/javascripts/notificationPanel.js index 7c3e608de..c6e1f25bc 100644 --- a/web/app/assets/javascripts/notificationPanel.js +++ b/web/app/assets/javascripts/notificationPanel.js @@ -213,7 +213,7 @@ }) .fail(function() { isLoading = false; - app.ajaxError(); + app.ajaxError(arguments); }) } @@ -1375,7 +1375,9 @@ events(); - populate(); + app.user().done(function(){ + populate(); + }) }; this.initialize = initialize; diff --git a/web/app/assets/javascripts/scheduled_session.js.erb b/web/app/assets/javascripts/scheduled_session.js.erb index 969f9449d..cf75275e1 100644 --- a/web/app/assets/javascripts/scheduled_session.js.erb +++ b/web/app/assets/javascripts/scheduled_session.js.erb @@ -1054,7 +1054,7 @@ context.JK.GenreSelectorHelper.render('#create-session-genre'); - inviteMusiciansUtil.loadFriends(); + //inviteMusiciansUtil.loadFriends(); context.JK.dropdown($screen.find('#session-musician-access')); context.JK.dropdown($screen.find('#session-fans-access')); diff --git a/web/app/assets/javascripts/sidebar.js b/web/app/assets/javascripts/sidebar.js index d60d59868..cf733c451 100644 --- a/web/app/assets/javascripts/sidebar.js +++ b/web/app/assets/javascripts/sidebar.js @@ -13,6 +13,7 @@ var notificationPanel = null; var chatPanel = null; var me = null; + var $sidebar = null; function initializeSearchPanel() { $('#search_text_type').change(function() { @@ -39,7 +40,9 @@ function initializeFriendsPanel() { $('#sidebar-search-header').hide(); - refreshFriends(); + app.user().done(function() { + refreshFriends(); + }) return false; } @@ -406,11 +409,24 @@ me = this; invitationDialog = invitationDialogInstance; textMessageDialog = textMessageDialogInstance; - events(); - initializeSearchPanel(); - initializeFriendsPanel(); - initializeChatPanel(); - initializeNotificationsPanel(); + $sidebar = $('#sidebar-div') + app.user() + .done(function() { + events(); + initializeSearchPanel(); + initializeFriendsPanel(); + initializeChatPanel(); + initializeNotificationsPanel(); + }) + .fail(function(arg1) { + if(arg1 == "not_logged_in") { + $('#search-input').attr('disabled', 'disabled') + $('.sidebar .invite-friend-row').click(function() { + app.layout.showDialog('login-required-dialog') + }); + $sidebar.addClass('not-logged-in') + } + }) }; this.refreshFriends = refreshFriends; diff --git a/web/app/assets/stylesheets/client/home.css.scss b/web/app/assets/stylesheets/client/home.css.scss index d9b7d9d45..9263fa2d7 100644 --- a/web/app/assets/stylesheets/client/home.css.scss +++ b/web/app/assets/stylesheets/client/home.css.scss @@ -8,6 +8,10 @@ background-repeat: no-repeat; background-position: bottom left; border: 1px solid $translucent1; + + &.not-logged-in { + opacity:0.6; + } } .homecard.createsession { background-image: url(/assets/content/bkg_home_create.jpg); diff --git a/web/app/assets/stylesheets/client/sidebar.css.scss b/web/app/assets/stylesheets/client/sidebar.css.scss index 17c975616..59a3bdfb5 100644 --- a/web/app/assets/stylesheets/client/sidebar.css.scss +++ b/web/app/assets/stylesheets/client/sidebar.css.scss @@ -5,6 +5,10 @@ background-color: $ColorElementPrimary; + &.not-logged-in { + opacity:0.6; + } + .panel-header { margin:0px; padding:0px; diff --git a/web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss b/web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss new file mode 100644 index 000000000..bc27a60ed --- /dev/null +++ b/web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss @@ -0,0 +1,12 @@ +#login-required-dialog { + + width:455px; + + p { + margin:0 0 20px 0; + } + + .buttons { + margin-top:20px; + } +} \ No newline at end of file diff --git a/web/app/controllers/api_genres_controller.rb b/web/app/controllers/api_genres_controller.rb index c413bf1f2..293552737 100644 --- a/web/app/controllers/api_genres_controller.rb +++ b/web/app/controllers/api_genres_controller.rb @@ -1,8 +1,5 @@ class ApiGenresController < ApiController - # have to be signed in currently to see this screen - before_filter :api_signed_in_user - respond_to :json def index diff --git a/web/app/controllers/api_instruments_controller.rb b/web/app/controllers/api_instruments_controller.rb index fc2c44fd9..c5f10bd49 100644 --- a/web/app/controllers/api_instruments_controller.rb +++ b/web/app/controllers/api_instruments_controller.rb @@ -1,8 +1,5 @@ class ApiInstrumentsController < ApiController - # have to be signed in currently to see this screen - before_filter :api_signed_in_user - respond_to :json def index diff --git a/web/app/helpers/sessions_helper.rb b/web/app/helpers/sessions_helper.rb index 3545c3d05..6665b8c00 100644 --- a/web/app/helpers/sessions_helper.rb +++ b/web/app/helpers/sessions_helper.rb @@ -26,6 +26,10 @@ module SessionsHelper !current_user.nil? end + def logged_in_not_logged_in_class + signed_in? ? "logged-in" : "not-logged-in" + end + def current_user=(user) @current_user = user end diff --git a/web/app/views/clients/_header.html.erb b/web/app/views/clients/_header.html.erb index 855f0e988..de9015e66 100644 --- a/web/app/views/clients/_header.html.erb +++ b/web/app/views/clients/_header.html.erb @@ -13,8 +13,8 @@ <% if Rails.application.config.jam_tracks_available %> - - + <% end %> diff --git a/web/app/views/clients/_home.html.slim b/web/app/views/clients/_home.html.slim index 8130e82cc..2c07e10b2 100644 --- a/web/app/views/clients/_home.html.slim +++ b/web/app/views/clients/_home.html.slim @@ -1,4 +1,4 @@ -.screen layout="screen" layout-id="home" +.screen.no-login-required layout="screen" layout-id="home" -if Rails.configuration.show_jamblaster_notice #jamblaster-notice a href='https://www.youtube.com/watch?v=gAJAIHMyois' rel="external" @@ -15,23 +15,23 @@ / individual spells span those spaces -if @nativeClient .grid layout-grid="2x12" - .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" + .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" class="#{logged_in_not_logged_in_class}" h2 create session .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" + .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" class="#{logged_in_not_logged_in_class}" h2 find session .homebox-info /! 1 session invitation, 19 public sessions active - .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" + .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" class="#{logged_in_not_logged_in_class}" h2 feed .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" + .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" class="#{logged_in_not_logged_in_class}" h2 musicians .homebox-info /! 5 followers, 3 following - .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" + .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" class="#{logged_in_not_logged_in_class}" h2 bands .homebox-info /! 1 session invitation, 19 public sessions active @@ -40,33 +40,33 @@ h2 jamtracks .homebox-info /! 5 followers, 3 following - .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" + .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" class="#{logged_in_not_logged_in_class}" h2 profile .homebox-info /! 5 followers, 3 following - .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" + .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" class="#{logged_in_not_logged_in_class}" h2 account .homebox-info /! free service level -else .grid layout-grid="2x12" - .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" + .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" class="#{logged_in_not_logged_in_class}" h2 create session .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" + .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" class="#{logged_in_not_logged_in_class}" h2 find session .homebox-info /! 1 session invitation, 19 public sessions active - .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" + .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" class="#{logged_in_not_logged_in_class}" h2 feed .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" + .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" class="#{logged_in_not_logged_in_class}" h2 musicians .homebox-info /! 5 followers, 3 following - .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" + .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" class="#{logged_in_not_logged_in_class}" h2 bands .homebox-info -if jamtracks @@ -75,11 +75,11 @@ h2 jamtracks .homebox-info /! 5 followers, 3 following - .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" + .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" class="#{logged_in_not_logged_in_class}" h2 profile .homebox-info /! 5 followers, 3 following - .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" + .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" class="#{logged_in_not_logged_in_class}" h2 account .homebox-info /! free service level diff --git a/web/app/views/clients/_jamtrack.html.haml b/web/app/views/clients/_jamtrack.html.haml index ba076ee19..bbb85a697 100644 --- a/web/app/views/clients/_jamtrack.html.haml +++ b/web/app/views/clients/_jamtrack.html.haml @@ -1,4 +1,4 @@ -%div{ layout: 'screen', :'layout-id' => 'jamtrack', id: 'jamtrackScreen', :class => 'screen secondary'} +%div{ layout: 'screen', :'layout-id' => 'jamtrack', id: 'jamtrackScreen', :class => 'screen secondary no-login-required'} .content .content-head .content-icon= image_tag("content/icon_jamtracks.png", {:height => 19, :width => 19}) diff --git a/web/app/views/clients/index.html.erb b/web/app/views/clients/index.html.erb index 3f1ad8a1b..ebba73cf6 100644 --- a/web/app/views/clients/index.html.erb +++ b/web/app/views/clients/index.html.erb @@ -109,20 +109,7 @@ JK.currentUserName = null; JK.currentUserMusician = null; JK.currentUserAdmin = false; - - // you need to be logged in to use this part of the interface. - // save original URL, and redirect to the home page - logger.debug("redirecting back to / because not logged in") - - var redirectPath= '?redirect-to=' + encodeURIComponent(JK.locationPath()); - if(gon.isNativeClient) { - window.location.href = '/signin' + redirectPath; - } - else { - window.location.href = '/' + redirectPath; - } - - <% end %> + <% end %> // Some things can't be initialized until we're connected. Put them here. @@ -289,6 +276,8 @@ JK.ClientUpdateInstance.check() JK.app.initialRouting(); + + JK.hideCurtain(300); } @@ -304,10 +293,10 @@ JK.RecordingUtils.init(); - // Let's get things rolling... - if (JK.currentUserId) { + JK.app.initialize(); - JK.app.initialize(); + // Let's get things rolling... + if (JK.currentUserId) { JK.JamServer.registerMessageCallback(JK.MessageType.CLIENT_UPDATE, function(header, payload) { // do a client update early check upon initialization @@ -315,7 +304,7 @@ }); - JK.TickDuration('.feed-entry.music-session-history-entry .inprogress .tick-duration'); + JK.TickDuration('.feed-entry.music-session-history-entry .inprogress .tick-duration'); JK.JamServer.connect() // singleton here defined in JamServer.js .done(function() { @@ -328,6 +317,9 @@ // this ensures that there is always a CurrentSessionModel, even if it's for a non-active session JK.CurrentSessionModel = new JK.SessionModel(JK.app, JK.JamServer, window.jamClient, null); } + else { + _initAfterConnect(false); + } JK.bindHoverEvents(); }) diff --git a/web/app/views/dialogs/_dialogs.html.haml b/web/app/views/dialogs/_dialogs.html.haml index 2b7ac1206..164eb93f8 100644 --- a/web/app/views/dialogs/_dialogs.html.haml +++ b/web/app/views/dialogs/_dialogs.html.haml @@ -34,3 +34,4 @@ = render 'dialogs/adjustGearSpeedDialog' = render 'dialogs/openJamTrackDialog' = render 'dialogs/openBackingTrackDialog' += render 'dialogs/loginRequiredDialog' diff --git a/web/app/views/dialogs/_loginRequiredDialog.html.slim b/web/app/views/dialogs/_loginRequiredDialog.html.slim new file mode 100644 index 000000000..4b979e68d --- /dev/null +++ b/web/app/views/dialogs/_loginRequiredDialog.html.slim @@ -0,0 +1,20 @@ +.dialog.dialog-overlay-sm layout='dialog' layout-id='login-required-dialog' id='login-required-dialog' + .content-head + = image_tag "content/icon_alert.png", {:width => 24, :height => 24, :class => 'content-icon' } + h1 Login Required + + .dialog-inner + p + a href="/signup" Sign Up + |  or  + a href="/signin" Sign In + |  to access most functionality on this page. + p + | However, you can browse for  + a class="go-to-jamtracks" href='/client#/jamtrack' JamTracks + |  without logging in. + br + .clearall + .buttons + .right + a.button-orange class='btnClose' layout-action='close' CLOSE \ No newline at end of file diff --git a/web/spec/controllers/api_jam_tracks_controller_spec.rb b/web/spec/controllers/api_jam_tracks_controller_spec.rb index 357cb8737..baeb7d1e3 100644 --- a/web/spec/controllers/api_jam_tracks_controller_spec.rb +++ b/web/spec/controllers/api_jam_tracks_controller_spec.rb @@ -60,19 +60,6 @@ describe ApiJamTracksController do json["next"].should be_nil json["jamtracks"].length.should == 2 end - - it "lists owned tracks" do - get :downloads - response.should be_success - json = JSON.parse(response.body) - json['downloads'].should have(0).items - - right = JamTrackRight.create(:user=>@user, :jam_track=>@jam_track) - get :downloads - response.should be_success - json = JSON.parse(response.body) - json['downloads'].should have(1).items - end it "finds a download" do #get "/download/#{right.id}/" diff --git a/web/spec/features/authentication_pages_spec.rb b/web/spec/features/authentication_pages_spec.rb index 7aea9cb9d..70aae8a2b 100644 --- a/web/spec/features/authentication_pages_spec.rb +++ b/web/spec/features/authentication_pages_spec.rb @@ -62,7 +62,8 @@ describe "Authentication", :js => true, :type => :feature, :capybara_feature => find('.userinfo .sign-out a').trigger(:click) end - it { find('h1', text: 'Play music together over the Internet as if in the same room') } + # after logging out, we keep you at /client + it { find('#profile a.signin', text: 'Sign Up') } end end end diff --git a/web/spec/features/in_session_spec.rb b/web/spec/features/in_session_spec.rb index ef96b1deb..a17f0d16a 100644 --- a/web/spec/features/in_session_spec.rb +++ b/web/spec/features/in_session_spec.rb @@ -28,7 +28,9 @@ describe "In a Session", :js => true, :type => :feature, :capybara_feature => tr sign_in_poltergeist finder visit "/client#/findSession" expect(page).to have_selector('#no-active-sessions') # verify private session is not found - sign_out_poltergeist(validate: true) + #sign_out_poltergeist(validate: true) + visit "/" + should_be_at_root end in_client(user) do set_session_access :public diff --git a/web/spec/features/profile_menu_spec.rb b/web/spec/features/profile_menu_spec.rb index 68ea06c8b..a4d0e15e2 100644 --- a/web/spec/features/profile_menu_spec.rb +++ b/web/spec/features/profile_menu_spec.rb @@ -53,7 +53,7 @@ describe "Profile Menu", :js => true, :type => :feature, :capybara_feature => tr click_link 'Sign Out' end - it { should_be_at_root } + it { should_be_at_logged_out_client } end describe "Download App link" do diff --git a/web/spec/features/signin_spec.rb b/web/spec/features/signin_spec.rb index 689b8251b..ad4f7dfec 100644 --- a/web/spec/features/signin_spec.rb +++ b/web/spec/features/signin_spec.rb @@ -175,7 +175,7 @@ describe "signin" do click_button "SIGN IN" end - find('h1', text: 'Play music together over the Internet as if in the same room') + should_be_at_logged_out_client end # if a cookie with the default domain is found with another, delete the one with the default domain @@ -201,7 +201,7 @@ describe "signin" do click_button "SIGN IN" end - find('h1', text: 'Play music together over the Internet as if in the same room') + should_be_at_logged_out_client delete_called.should be_true end @@ -211,6 +211,23 @@ describe "signin" do sign_in_poltergeist(user) sign_out_poltergeist + + wait_until_curtain_gone + + # musicians homecard should be disabled + find('.homecard.musicians.not-logged-in').trigger(:click) + find('h1', text: 'Login Required') + find('.btnClose').trigger(:click) + + # profile homecard should be disabled (this one is handled in homeScreen.js instead of in layout.js) + find('.homecard.profile.not-logged-in').trigger(:click) + find('h1', text: 'Login Required') + find('.btnClose').trigger(:click) + + # sidebar should be disabled + find('[layout-id="panelSearch"] [layout-panel="expanded"] [layout-panel="header"]').trigger(:click) + find('h1', text: 'Login Required') + find('.btnClose').trigger(:click) end diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index 8982fd5a1..7a89d9b23 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -200,7 +200,7 @@ end def sign_out_poltergeist(options = {}) open_user_dropdown click_link 'Sign Out' - should_be_at_signin if options[:validate] + should_be_at_logged_out_client if options[:validate] end def open_user_dropdown @@ -221,6 +221,11 @@ def should_be_at_signin find('h1', text: 'sign in or register') end +def should_be_at_logged_out_client + find('#profile a.signin', text: 'Sign Up') + find('.musicians.not-logged-in') +end + def leave_music_session_sleep_delay # add a buffer to ensure WSG has enough time to expire sleep_dur = (Rails.application.config.websocket_gateway_connect_time_stale_browser + From 477df086b0172cc7cc75d4b012076476e6d67bd5 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 11 Mar 2015 16:53:12 -0500 Subject: [PATCH 4/5] Revert "* VRFS-2913 - allow /client to be accessed without being logged in" This reverts commit 0a869e91e3abd2aa6d2b90dc8000281465e59309. --- web/app/assets/javascripts/accounts.js | 6 +-- .../javascripts/dialog/loginRequiredDialog.js | 45 ------------------- .../javascripts/everywhere/everywhere.js | 3 -- web/app/assets/javascripts/findSession.js | 2 - web/app/assets/javascripts/homeScreen.js | 14 +----- .../javascripts/jam_track_utils.js.coffee | 2 +- web/app/assets/javascripts/jamkazam.js | 32 ++----------- web/app/assets/javascripts/layout.js | 18 +------- .../assets/javascripts/notificationPanel.js | 6 +-- .../javascripts/scheduled_session.js.erb | 2 +- web/app/assets/javascripts/sidebar.js | 28 +++--------- .../assets/stylesheets/client/home.css.scss | 4 -- .../stylesheets/client/sidebar.css.scss | 4 -- .../dialogs/loginRequiredDialog.css.scss | 12 ----- web/app/controllers/api_genres_controller.rb | 3 ++ .../controllers/api_instruments_controller.rb | 3 ++ web/app/helpers/sessions_helper.rb | 4 -- web/app/views/clients/_header.html.erb | 4 +- web/app/views/clients/_home.html.slim | 30 ++++++------- web/app/views/clients/_jamtrack.html.haml | 2 +- web/app/views/clients/index.html.erb | 28 +++++++----- web/app/views/dialogs/_dialogs.html.haml | 1 - .../dialogs/_loginRequiredDialog.html.slim | 20 --------- .../api_jam_tracks_controller_spec.rb | 13 ++++++ .../features/authentication_pages_spec.rb | 3 +- web/spec/features/in_session_spec.rb | 4 +- web/spec/features/profile_menu_spec.rb | 2 +- web/spec/features/signin_spec.rb | 21 +-------- web/spec/support/utilities.rb | 7 +-- 29 files changed, 80 insertions(+), 243 deletions(-) delete mode 100644 web/app/assets/javascripts/dialog/loginRequiredDialog.js delete mode 100644 web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss delete mode 100644 web/app/views/dialogs/_loginRequiredDialog.html.slim diff --git a/web/app/assets/javascripts/accounts.js b/web/app/assets/javascripts/accounts.js index 90b0c4e5e..64501695d 100644 --- a/web/app/assets/javascripts/accounts.js +++ b/web/app/assets/javascripts/accounts.js @@ -105,11 +105,9 @@ } function renderAccount() { - app.user().done(function() { rest.getUserDetail() - .done(populateAccount) - .error(app.ajaxError) - }) + .done(populateAccount) + .error(app.ajaxError) } function navToScheduledSessions() { diff --git a/web/app/assets/javascripts/dialog/loginRequiredDialog.js b/web/app/assets/javascripts/dialog/loginRequiredDialog.js deleted file mode 100644 index 6795614c1..000000000 --- a/web/app/assets/javascripts/dialog/loginRequiredDialog.js +++ /dev/null @@ -1,45 +0,0 @@ -(function(context,$) { - - "use strict"; - context.JK = context.JK || {}; - context.JK.LoginRequiredDialog = function(app) { - var logger = context.JK.logger; - var $dialog = null; - var dialogId = 'login-required-dialog'; - - function beforeShow(data) { - } - - function afterShow(data) { - } - - function afterHide() { - } - - function events() { - $dialog.find('.go-to-jamtracks').click(function() { - app.layout.closeDialog(dialogId) - context.location.href = $(this).attr('href') - }) - } - - function initialize() { - - var dialogBindings = { - 'beforeShow' : beforeShow, - 'afterShow' : afterShow, - 'afterHide': afterHide - }; - - app.bindDialog(dialogId, dialogBindings); - - $dialog = $('#' + dialogId); - - events(); - } - - this.initialize = initialize; - }; - - return this; -})(window,jQuery); \ No newline at end of file diff --git a/web/app/assets/javascripts/everywhere/everywhere.js b/web/app/assets/javascripts/everywhere/everywhere.js index b8c0f62d5..4564cd9b0 100644 --- a/web/app/assets/javascripts/everywhere/everywhere.js +++ b/web/app/assets/javascripts/everywhere/everywhere.js @@ -127,9 +127,6 @@ var clientPreferencesDialog = new JK.ClientPreferencesDialog(app); clientPreferencesDialog.initialize(); - - var loginRequiredDialog = new JK.LoginRequiredDialog(app); - loginRequiredDialog.initialize(); } // wait 10 seconds diff --git a/web/app/assets/javascripts/findSession.js b/web/app/assets/javascripts/findSession.js index d3c4638c2..f54feb866 100644 --- a/web/app/assets/javascripts/findSession.js +++ b/web/app/assets/javascripts/findSession.js @@ -57,11 +57,9 @@ }) .fail(function(xhr, textStatus, errorMessage) { if (xhr.status === 404) { - logger.warn("unable to list active sessions (404)") // swallow 404 } else { - logger.warn("unable to list active sessions") app.ajaxError(xhr, textStatus, errorMessage); } }) diff --git a/web/app/assets/javascripts/homeScreen.js b/web/app/assets/javascripts/homeScreen.js index ec7b86d50..997927dbd 100644 --- a/web/app/assets/javascripts/homeScreen.js +++ b/web/app/assets/javascripts/homeScreen.js @@ -6,7 +6,6 @@ context.JK.HomeScreen = function(app) { var logger = context.JK.logger; var isFtueComplete = false; - var $screen = null; function beforeShow(data) { } @@ -87,20 +86,9 @@ var screenBindings = { 'beforeShow': beforeShow }; app.bindScreen('home', screenBindings); events(); - $screen = $('.screen[layout-id="home"]') - $screen.find('.profile').on('click', function() { - var $destination = $('[layout-id="profile"]'); - if(!context.JK.currentUserId && !$destination.is('.no-login-required')) { - // if there is no user and login is required, then stop user from clicknig through - app.layout.showDialog('login-required-dialog') - } - else - { + $('.profile').on('click', function() { context.location = '/client#/profile/' + context.JK.currentUserId; - } - - }); }; diff --git a/web/app/assets/javascripts/jam_track_utils.js.coffee b/web/app/assets/javascripts/jam_track_utils.js.coffee index 8ba73f592..2935665cc 100644 --- a/web/app/assets/javascripts/jam_track_utils.js.coffee +++ b/web/app/assets/javascripts/jam_track_utils.js.coffee @@ -16,7 +16,7 @@ class JamTrackUtils @rest.getShoppingCarts().done(this.displayCartIcon) displayCartIcon: (carts) => - cartLink = $("#header-shopping-cart") + cartLink = $("a[href='" + "/client#/shoppingCart" + "']") if carts.length > 0 cartLink.removeClass("hidden") else diff --git a/web/app/assets/javascripts/jamkazam.js b/web/app/assets/javascripts/jamkazam.js index 2bc31b957..db0615510 100644 --- a/web/app/assets/javascripts/jamkazam.js +++ b/web/app/assets/javascripts/jamkazam.js @@ -132,9 +132,6 @@ logger.error("Unexpected ajax error: " + textStatus + ", msg:" + errorMessage); app.notify({title: "Oops!", text: "What you were looking for is gone now."}); } - else if(jqXHR.status === 403) { - logger.debug("not logged in"); - } else if (jqXHR.status === 422) { logger.error("Unexpected ajax error: " + textStatus + ", msg: " + errorMessage + ", response: " + jqXHR.responseText); // present a nicer message @@ -285,37 +282,20 @@ var hash = context.location.hash; - var screen = 'home' try { - var location = context.RouteMap.parse(hash); - screen = location.page.substring(1); // remove leading slash + context.RouteMap.parse(hash); } catch (e) { logger.debug("ignoring bogus screen name: %o", hash) hash = null; } - - var $destination = $('[layout-id="' + screen + '"]'); - - if(!context.JK.currentUserId && !$destination.is('.no-login-required')) { - logger.debug("not logged in so redirected to login from screen: " + screen) - var redirectPath= '?redirect-to=' + encodeURIComponent(JK.locationPath()); - if(gon.isNativeClient) { - window.location.href = '/signin' + redirectPath; - } - else { - window.location.href = '/' + redirectPath; - } - return; - } - - var url = '/client#/' + screen; + var url = '/client#/home'; if (hash) { url = hash; } - logger.debug("jamkazam: Changing screen to " + url + " (hash=" + hash + ")") ; + logger.debug("Changing screen to " + url); context.location = url; } @@ -397,11 +377,7 @@ app.notify({title: "Unable to Load User", text: "You should reload the page."}) }); } - } - else { - userDeferred = new $.Deferred(); - userDeferred.reject('not_logged_in'); - } + } // if userDeferred $(document).triggerHandler('JAMKAZAM_READY', {app:app}) diff --git a/web/app/assets/javascripts/layout.js b/web/app/assets/javascripts/layout.js index 1179f71b2..6c40f596d 100644 --- a/web/app/assets/javascripts/layout.js +++ b/web/app/assets/javascripts/layout.js @@ -415,15 +415,8 @@ } var destination = $(evt.currentTarget).attr('layout-link'); - var $destination = $('[layout-id="' + destination + '"]'); - - var destinationType = $destination.attr("layout"); + var destinationType = $('[layout-id="' + destination + '"]').attr("layout"); if (destinationType === "screen") { - if(!context.JK.currentUserId && !$destination.is('.no-login-required')) { - // there is no user, and this item does not support 'no-login', so warn user - showDialog('login-required-dialog'); - return; - } context.location = '/client#/' + destination; } else if (destinationType === "dialog") { showDialog(destination); @@ -555,7 +548,7 @@ var accepted = screenEvent(previousScreen, 'beforeHide', data); if(accepted === false) return; - logger.debug("layout: changing screen to " + currentScreen); + logger.debug("Changing screen to " + currentScreen); $(document).triggerHandler(EVENTS.SCREEN_CHANGED, {previousScreen: previousScreen, newScreen: currentScreen}) @@ -702,7 +695,6 @@ return null; } logger.debug("opening dialog: " + dialog) - var $overlay = $('.dialog-overlay') if (opts.sizeOverlayToContent) { @@ -735,12 +727,6 @@ function panelHeaderClicked(evt) { evt.preventDefault(); - - if(!context.JK.currentUserId) { - showDialog('login-required-dialog'); - return false; - } - expandedPanel = $(evt.currentTarget).closest('[layout="panel"]').attr("layout-id"); layout(); return false; diff --git a/web/app/assets/javascripts/notificationPanel.js b/web/app/assets/javascripts/notificationPanel.js index c6e1f25bc..7c3e608de 100644 --- a/web/app/assets/javascripts/notificationPanel.js +++ b/web/app/assets/javascripts/notificationPanel.js @@ -213,7 +213,7 @@ }) .fail(function() { isLoading = false; - app.ajaxError(arguments); + app.ajaxError(); }) } @@ -1375,9 +1375,7 @@ events(); - app.user().done(function(){ - populate(); - }) + populate(); }; this.initialize = initialize; diff --git a/web/app/assets/javascripts/scheduled_session.js.erb b/web/app/assets/javascripts/scheduled_session.js.erb index cf75275e1..969f9449d 100644 --- a/web/app/assets/javascripts/scheduled_session.js.erb +++ b/web/app/assets/javascripts/scheduled_session.js.erb @@ -1054,7 +1054,7 @@ context.JK.GenreSelectorHelper.render('#create-session-genre'); - //inviteMusiciansUtil.loadFriends(); + inviteMusiciansUtil.loadFriends(); context.JK.dropdown($screen.find('#session-musician-access')); context.JK.dropdown($screen.find('#session-fans-access')); diff --git a/web/app/assets/javascripts/sidebar.js b/web/app/assets/javascripts/sidebar.js index cf733c451..d60d59868 100644 --- a/web/app/assets/javascripts/sidebar.js +++ b/web/app/assets/javascripts/sidebar.js @@ -13,7 +13,6 @@ var notificationPanel = null; var chatPanel = null; var me = null; - var $sidebar = null; function initializeSearchPanel() { $('#search_text_type').change(function() { @@ -40,9 +39,7 @@ function initializeFriendsPanel() { $('#sidebar-search-header').hide(); - app.user().done(function() { - refreshFriends(); - }) + refreshFriends(); return false; } @@ -409,24 +406,11 @@ me = this; invitationDialog = invitationDialogInstance; textMessageDialog = textMessageDialogInstance; - $sidebar = $('#sidebar-div') - app.user() - .done(function() { - events(); - initializeSearchPanel(); - initializeFriendsPanel(); - initializeChatPanel(); - initializeNotificationsPanel(); - }) - .fail(function(arg1) { - if(arg1 == "not_logged_in") { - $('#search-input').attr('disabled', 'disabled') - $('.sidebar .invite-friend-row').click(function() { - app.layout.showDialog('login-required-dialog') - }); - $sidebar.addClass('not-logged-in') - } - }) + events(); + initializeSearchPanel(); + initializeFriendsPanel(); + initializeChatPanel(); + initializeNotificationsPanel(); }; this.refreshFriends = refreshFriends; diff --git a/web/app/assets/stylesheets/client/home.css.scss b/web/app/assets/stylesheets/client/home.css.scss index 9263fa2d7..d9b7d9d45 100644 --- a/web/app/assets/stylesheets/client/home.css.scss +++ b/web/app/assets/stylesheets/client/home.css.scss @@ -8,10 +8,6 @@ background-repeat: no-repeat; background-position: bottom left; border: 1px solid $translucent1; - - &.not-logged-in { - opacity:0.6; - } } .homecard.createsession { background-image: url(/assets/content/bkg_home_create.jpg); diff --git a/web/app/assets/stylesheets/client/sidebar.css.scss b/web/app/assets/stylesheets/client/sidebar.css.scss index 59a3bdfb5..17c975616 100644 --- a/web/app/assets/stylesheets/client/sidebar.css.scss +++ b/web/app/assets/stylesheets/client/sidebar.css.scss @@ -5,10 +5,6 @@ background-color: $ColorElementPrimary; - &.not-logged-in { - opacity:0.6; - } - .panel-header { margin:0px; padding:0px; diff --git a/web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss b/web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss deleted file mode 100644 index bc27a60ed..000000000 --- a/web/app/assets/stylesheets/dialogs/loginRequiredDialog.css.scss +++ /dev/null @@ -1,12 +0,0 @@ -#login-required-dialog { - - width:455px; - - p { - margin:0 0 20px 0; - } - - .buttons { - margin-top:20px; - } -} \ No newline at end of file diff --git a/web/app/controllers/api_genres_controller.rb b/web/app/controllers/api_genres_controller.rb index 293552737..c413bf1f2 100644 --- a/web/app/controllers/api_genres_controller.rb +++ b/web/app/controllers/api_genres_controller.rb @@ -1,5 +1,8 @@ class ApiGenresController < ApiController + # have to be signed in currently to see this screen + before_filter :api_signed_in_user + respond_to :json def index diff --git a/web/app/controllers/api_instruments_controller.rb b/web/app/controllers/api_instruments_controller.rb index c5f10bd49..fc2c44fd9 100644 --- a/web/app/controllers/api_instruments_controller.rb +++ b/web/app/controllers/api_instruments_controller.rb @@ -1,5 +1,8 @@ class ApiInstrumentsController < ApiController + # have to be signed in currently to see this screen + before_filter :api_signed_in_user + respond_to :json def index diff --git a/web/app/helpers/sessions_helper.rb b/web/app/helpers/sessions_helper.rb index 6665b8c00..3545c3d05 100644 --- a/web/app/helpers/sessions_helper.rb +++ b/web/app/helpers/sessions_helper.rb @@ -26,10 +26,6 @@ module SessionsHelper !current_user.nil? end - def logged_in_not_logged_in_class - signed_in? ? "logged-in" : "not-logged-in" - end - def current_user=(user) @current_user = user end diff --git a/web/app/views/clients/_header.html.erb b/web/app/views/clients/_header.html.erb index de9015e66..855f0e988 100644 --- a/web/app/views/clients/_header.html.erb +++ b/web/app/views/clients/_header.html.erb @@ -13,8 +13,8 @@ <% if Rails.application.config.jam_tracks_available %> - + <% end %> diff --git a/web/app/views/clients/_home.html.slim b/web/app/views/clients/_home.html.slim index 2c07e10b2..8130e82cc 100644 --- a/web/app/views/clients/_home.html.slim +++ b/web/app/views/clients/_home.html.slim @@ -1,4 +1,4 @@ -.screen.no-login-required layout="screen" layout-id="home" +.screen layout="screen" layout-id="home" -if Rails.configuration.show_jamblaster_notice #jamblaster-notice a href='https://www.youtube.com/watch?v=gAJAIHMyois' rel="external" @@ -15,23 +15,23 @@ / individual spells span those spaces -if @nativeClient .grid layout-grid="2x12" - .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" class="#{logged_in_not_logged_in_class}" + .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" h2 create session .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" class="#{logged_in_not_logged_in_class}" + .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" h2 find session .homebox-info /! 1 session invitation, 19 public sessions active - .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" class="#{logged_in_not_logged_in_class}" + .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" h2 feed .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" class="#{logged_in_not_logged_in_class}" + .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" h2 musicians .homebox-info /! 5 followers, 3 following - .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" class="#{logged_in_not_logged_in_class}" + .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" h2 bands .homebox-info /! 1 session invitation, 19 public sessions active @@ -40,33 +40,33 @@ h2 jamtracks .homebox-info /! 5 followers, 3 following - .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" class="#{logged_in_not_logged_in_class}" + .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" h2 profile .homebox-info /! 5 followers, 3 following - .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" class="#{logged_in_not_logged_in_class}" + .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" h2 account .homebox-info /! free service level -else .grid layout-grid="2x12" - .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" class="#{logged_in_not_logged_in_class}" + .homecard.createsession layout-grid-columns="4" layout-grid-position="0,0" layout-grid-rows="1" layout-link="createSession" type="createSession" h2 create session .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" class="#{logged_in_not_logged_in_class}" + .homecard.findsession layout-grid-columns="4" layout-grid-position="4,0" layout-grid-rows="1" layout-link="findSession" type="findSession" h2 find session .homebox-info /! 1 session invitation, 19 public sessions active - .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" class="#{logged_in_not_logged_in_class}" + .homecard.feed layout-grid-columns="4" layout-grid-position="8,0" layout-grid-rows="1" layout-link="feed" h2 feed .homebox-info /! 4 friends online, 2 currently in sessions - .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" class="#{logged_in_not_logged_in_class}" + .homecard.musicians layout-grid-columns=small_tile_size layout-grid-position=column_positions[0] layout-grid-rows="1" layout-link="musicians" h2 musicians .homebox-info /! 5 followers, 3 following - .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" class="#{logged_in_not_logged_in_class}" + .homecard.bands layout-grid-columns=small_tile_size layout-grid-position=column_positions[1] layout-grid-rows="1" layout-link="bands" h2 bands .homebox-info -if jamtracks @@ -75,11 +75,11 @@ h2 jamtracks .homebox-info /! 5 followers, 3 following - .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" class="#{logged_in_not_logged_in_class}" + .homecard.profile layout-grid-columns=small_tile_size layout-grid-position=column_positions[3] layout-grid-rows="1" h2 profile .homebox-info /! 5 followers, 3 following - .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" class="#{logged_in_not_logged_in_class}" + .homecard.account layout-grid-columns=small_tile_size layout-grid-position=column_positions[4] layout-grid-rows="1" layout-link="account" h2 account .homebox-info /! free service level diff --git a/web/app/views/clients/_jamtrack.html.haml b/web/app/views/clients/_jamtrack.html.haml index bbb85a697..ba076ee19 100644 --- a/web/app/views/clients/_jamtrack.html.haml +++ b/web/app/views/clients/_jamtrack.html.haml @@ -1,4 +1,4 @@ -%div{ layout: 'screen', :'layout-id' => 'jamtrack', id: 'jamtrackScreen', :class => 'screen secondary no-login-required'} +%div{ layout: 'screen', :'layout-id' => 'jamtrack', id: 'jamtrackScreen', :class => 'screen secondary'} .content .content-head .content-icon= image_tag("content/icon_jamtracks.png", {:height => 19, :width => 19}) diff --git a/web/app/views/clients/index.html.erb b/web/app/views/clients/index.html.erb index ebba73cf6..3f1ad8a1b 100644 --- a/web/app/views/clients/index.html.erb +++ b/web/app/views/clients/index.html.erb @@ -109,7 +109,20 @@ JK.currentUserName = null; JK.currentUserMusician = null; JK.currentUserAdmin = false; - <% end %> + + // you need to be logged in to use this part of the interface. + // save original URL, and redirect to the home page + logger.debug("redirecting back to / because not logged in") + + var redirectPath= '?redirect-to=' + encodeURIComponent(JK.locationPath()); + if(gon.isNativeClient) { + window.location.href = '/signin' + redirectPath; + } + else { + window.location.href = '/' + redirectPath; + } + + <% end %> // Some things can't be initialized until we're connected. Put them here. @@ -276,8 +289,6 @@ JK.ClientUpdateInstance.check() JK.app.initialRouting(); - - JK.hideCurtain(300); } @@ -293,18 +304,18 @@ JK.RecordingUtils.init(); - JK.app.initialize(); - - // Let's get things rolling... + // Let's get things rolling... if (JK.currentUserId) { + JK.app.initialize(); + JK.JamServer.registerMessageCallback(JK.MessageType.CLIENT_UPDATE, function(header, payload) { // do a client update early check upon initialization JK.ClientUpdateInstance.runCheck(payload.product, payload.version, payload.uri, payload.size) }); - JK.TickDuration('.feed-entry.music-session-history-entry .inprogress .tick-duration'); + JK.TickDuration('.feed-entry.music-session-history-entry .inprogress .tick-duration'); JK.JamServer.connect() // singleton here defined in JamServer.js .done(function() { @@ -317,9 +328,6 @@ // this ensures that there is always a CurrentSessionModel, even if it's for a non-active session JK.CurrentSessionModel = new JK.SessionModel(JK.app, JK.JamServer, window.jamClient, null); } - else { - _initAfterConnect(false); - } JK.bindHoverEvents(); }) diff --git a/web/app/views/dialogs/_dialogs.html.haml b/web/app/views/dialogs/_dialogs.html.haml index 164eb93f8..2b7ac1206 100644 --- a/web/app/views/dialogs/_dialogs.html.haml +++ b/web/app/views/dialogs/_dialogs.html.haml @@ -34,4 +34,3 @@ = render 'dialogs/adjustGearSpeedDialog' = render 'dialogs/openJamTrackDialog' = render 'dialogs/openBackingTrackDialog' -= render 'dialogs/loginRequiredDialog' diff --git a/web/app/views/dialogs/_loginRequiredDialog.html.slim b/web/app/views/dialogs/_loginRequiredDialog.html.slim deleted file mode 100644 index 4b979e68d..000000000 --- a/web/app/views/dialogs/_loginRequiredDialog.html.slim +++ /dev/null @@ -1,20 +0,0 @@ -.dialog.dialog-overlay-sm layout='dialog' layout-id='login-required-dialog' id='login-required-dialog' - .content-head - = image_tag "content/icon_alert.png", {:width => 24, :height => 24, :class => 'content-icon' } - h1 Login Required - - .dialog-inner - p - a href="/signup" Sign Up - |  or  - a href="/signin" Sign In - |  to access most functionality on this page. - p - | However, you can browse for  - a class="go-to-jamtracks" href='/client#/jamtrack' JamTracks - |  without logging in. - br - .clearall - .buttons - .right - a.button-orange class='btnClose' layout-action='close' CLOSE \ No newline at end of file diff --git a/web/spec/controllers/api_jam_tracks_controller_spec.rb b/web/spec/controllers/api_jam_tracks_controller_spec.rb index baeb7d1e3..357cb8737 100644 --- a/web/spec/controllers/api_jam_tracks_controller_spec.rb +++ b/web/spec/controllers/api_jam_tracks_controller_spec.rb @@ -60,6 +60,19 @@ describe ApiJamTracksController do json["next"].should be_nil json["jamtracks"].length.should == 2 end + + it "lists owned tracks" do + get :downloads + response.should be_success + json = JSON.parse(response.body) + json['downloads'].should have(0).items + + right = JamTrackRight.create(:user=>@user, :jam_track=>@jam_track) + get :downloads + response.should be_success + json = JSON.parse(response.body) + json['downloads'].should have(1).items + end it "finds a download" do #get "/download/#{right.id}/" diff --git a/web/spec/features/authentication_pages_spec.rb b/web/spec/features/authentication_pages_spec.rb index 70aae8a2b..7aea9cb9d 100644 --- a/web/spec/features/authentication_pages_spec.rb +++ b/web/spec/features/authentication_pages_spec.rb @@ -62,8 +62,7 @@ describe "Authentication", :js => true, :type => :feature, :capybara_feature => find('.userinfo .sign-out a').trigger(:click) end - # after logging out, we keep you at /client - it { find('#profile a.signin', text: 'Sign Up') } + it { find('h1', text: 'Play music together over the Internet as if in the same room') } end end end diff --git a/web/spec/features/in_session_spec.rb b/web/spec/features/in_session_spec.rb index a17f0d16a..ef96b1deb 100644 --- a/web/spec/features/in_session_spec.rb +++ b/web/spec/features/in_session_spec.rb @@ -28,9 +28,7 @@ describe "In a Session", :js => true, :type => :feature, :capybara_feature => tr sign_in_poltergeist finder visit "/client#/findSession" expect(page).to have_selector('#no-active-sessions') # verify private session is not found - #sign_out_poltergeist(validate: true) - visit "/" - should_be_at_root + sign_out_poltergeist(validate: true) end in_client(user) do set_session_access :public diff --git a/web/spec/features/profile_menu_spec.rb b/web/spec/features/profile_menu_spec.rb index a4d0e15e2..68ea06c8b 100644 --- a/web/spec/features/profile_menu_spec.rb +++ b/web/spec/features/profile_menu_spec.rb @@ -53,7 +53,7 @@ describe "Profile Menu", :js => true, :type => :feature, :capybara_feature => tr click_link 'Sign Out' end - it { should_be_at_logged_out_client } + it { should_be_at_root } end describe "Download App link" do diff --git a/web/spec/features/signin_spec.rb b/web/spec/features/signin_spec.rb index ad4f7dfec..689b8251b 100644 --- a/web/spec/features/signin_spec.rb +++ b/web/spec/features/signin_spec.rb @@ -175,7 +175,7 @@ describe "signin" do click_button "SIGN IN" end - should_be_at_logged_out_client + find('h1', text: 'Play music together over the Internet as if in the same room') end # if a cookie with the default domain is found with another, delete the one with the default domain @@ -201,7 +201,7 @@ describe "signin" do click_button "SIGN IN" end - should_be_at_logged_out_client + find('h1', text: 'Play music together over the Internet as if in the same room') delete_called.should be_true end @@ -211,23 +211,6 @@ describe "signin" do sign_in_poltergeist(user) sign_out_poltergeist - - wait_until_curtain_gone - - # musicians homecard should be disabled - find('.homecard.musicians.not-logged-in').trigger(:click) - find('h1', text: 'Login Required') - find('.btnClose').trigger(:click) - - # profile homecard should be disabled (this one is handled in homeScreen.js instead of in layout.js) - find('.homecard.profile.not-logged-in').trigger(:click) - find('h1', text: 'Login Required') - find('.btnClose').trigger(:click) - - # sidebar should be disabled - find('[layout-id="panelSearch"] [layout-panel="expanded"] [layout-panel="header"]').trigger(:click) - find('h1', text: 'Login Required') - find('.btnClose').trigger(:click) end diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb index 7a89d9b23..8982fd5a1 100644 --- a/web/spec/support/utilities.rb +++ b/web/spec/support/utilities.rb @@ -200,7 +200,7 @@ end def sign_out_poltergeist(options = {}) open_user_dropdown click_link 'Sign Out' - should_be_at_logged_out_client if options[:validate] + should_be_at_signin if options[:validate] end def open_user_dropdown @@ -221,11 +221,6 @@ def should_be_at_signin find('h1', text: 'sign in or register') end -def should_be_at_logged_out_client - find('#profile a.signin', text: 'Sign Up') - find('.musicians.not-logged-in') -end - def leave_music_session_sleep_delay # add a buffer to ensure WSG has enough time to expire sleep_dur = (Rails.application.config.websocket_gateway_connect_time_stale_browser + From 5fa37abfb3b7546ab06480deb5927f2197c5cfd2 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 11 Mar 2015 17:02:03 -0500 Subject: [PATCH 5/5] * VRFS-2916 - adding redeemed boolean --- db/manifest | 3 ++- db/up/jam_track_redeemed.sql | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 db/up/jam_track_redeemed.sql diff --git a/db/manifest b/db/manifest index 6d9f1f63d..9cc4e1fac 100755 --- a/db/manifest +++ b/db/manifest @@ -259,4 +259,5 @@ recorded_jam_track_tracks.sql jam_track_jmep_data.sql add_jam_track_bitrates.sql jam_track_importer.sql -jam_track_pro_licensing_update.sql \ No newline at end of file +jam_track_pro_licensing_update.sql +jam_track_redeemed.sql \ No newline at end of file diff --git a/db/up/jam_track_redeemed.sql b/db/up/jam_track_redeemed.sql new file mode 100644 index 000000000..8a09cd56f --- /dev/null +++ b/db/up/jam_track_redeemed.sql @@ -0,0 +1 @@ +ALTER TABLE jam_track_rights ADD COLUMN redeemed BOOLEAN NOT NULL DEFAULT FALSE; \ No newline at end of file