Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop
This commit is contained in:
commit
9d3ee833a1
|
|
@ -121,3 +121,7 @@ scores_mod_connections.sql
|
|||
scores_create_schemas_and_extensions.sql
|
||||
scores_create_tables.sql
|
||||
remove_is_downloadable.sql
|
||||
scores_mod_connections2.sql
|
||||
track_download_counts.sql
|
||||
scores_mod_users2.sql
|
||||
user_bio.sql
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
-- fix locidispid should be bigint
|
||||
|
||||
ALTER TABLE connections DROP COLUMN locidispid;
|
||||
ALTER TABLE connections ADD COLUMN locidispid BIGINT;
|
||||
ALTER TABLE connections ALTER COLUMN locidispid SET NOT NULL;
|
||||
CREATE INDEX connections_locidispid_ndx ON connections (locidispid);
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
-- locidispid must be bigint
|
||||
|
||||
ALTER TABLE users DROP COLUMN locidispid;
|
||||
ALTER TABLE users ADD COLUMN locidispid BIGINT;
|
||||
ALTER TABLE users ALTER COLUMN locidispid SET DEFAULT 0;
|
||||
UPDATE users SET locidispid = 0;
|
||||
ALTER TABLE users ALTER COLUMN locidispid SET NOT NULL;
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
ALTER TABLE recorded_tracks ADD COLUMN download_count INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE recorded_tracks ADD COLUMN last_downloaded_at TIMESTAMP;
|
||||
|
||||
ALTER TABLE mixes ADD COLUMN download_count INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE mixes ADD COLUMN last_downloaded_at TIMESTAMP;
|
||||
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE users ALTER COLUMN biography TYPE TEXT;
|
||||
|
|
@ -124,6 +124,8 @@ require "jam_ruby/models/recording_play"
|
|||
require "jam_ruby/models/feed"
|
||||
require "jam_ruby/models/jam_isp"
|
||||
require "jam_ruby/models/geo_ip_blocks"
|
||||
require "jam_ruby/models/geo_ip_locations"
|
||||
require "jam_ruby/models/score"
|
||||
|
||||
include Jampb
|
||||
|
||||
|
|
|
|||
|
|
@ -56,27 +56,44 @@ module JamRuby
|
|||
end
|
||||
|
||||
if ip_address
|
||||
# todo turn ip_address string into a number, then fetch the locid and ispid and the other stuff...
|
||||
# turn ip_address string into a number, then fetch the isp and block records and update location info
|
||||
|
||||
addr = JamIsp.ip_to_num(ip_address)
|
||||
puts("============= JamIsp.ip_to_num returns #{addr} for #{ip_address} =============")
|
||||
#puts("============= JamIsp.ip_to_num returns #{addr} for #{ip_address} =============")
|
||||
|
||||
isp = JamIsp.lookup(addr)
|
||||
#puts("============= JamIsp.lookup returns #{isp.inspect} for #{addr} =============")
|
||||
if isp.nil? then ispid = 0 else ispid = isp.coid end
|
||||
puts("============= JamIsp.lookup returns #{ispid} for #{addr} =============")
|
||||
|
||||
block = GeoIpBlocks.lookup(addr)
|
||||
#puts("============= GeoIpBlocks.lookup returns #{block.inspect} for #{addr} =============")
|
||||
if block.nil? then locid = 0 else locid = block.locid end
|
||||
puts("============= GeoIpBlocks.lookup returns #{locid} for #{addr} =============")
|
||||
|
||||
locidispid = 0
|
||||
latitude = 0.0
|
||||
longitude = 0.0
|
||||
countrycode = 'US'
|
||||
region = 'TX'
|
||||
city = 'Austin'
|
||||
location = GeoIpLocations.lookup(locid)
|
||||
if location.nil?
|
||||
locidispid = 0
|
||||
latitude = 0.0
|
||||
longitude = 0.0
|
||||
countrycode = 'US'
|
||||
region = 'TX'
|
||||
city = 'Austin'
|
||||
else
|
||||
locidispid = locid*1000000+ispid
|
||||
latitude = location.latitude
|
||||
longitude = location.longitude
|
||||
countrycode = location.countrycode
|
||||
region = location.region
|
||||
city = location.city
|
||||
end
|
||||
|
||||
# todo stuff this stuff into the connection records
|
||||
conn.ip_address = ip_address
|
||||
conn.locidispid = locidispid
|
||||
conn.latitude = latitude
|
||||
conn.longitude = longitude
|
||||
conn.countrycode = countrycode
|
||||
conn.region = region
|
||||
conn.city = city
|
||||
conn.save!(validate: false)
|
||||
end
|
||||
|
||||
sql =<<SQL
|
||||
|
|
@ -188,30 +205,40 @@ SQL
|
|||
ConnectionManager.active_record_transaction do |connection_manager|
|
||||
conn = connection_manager.pg_conn
|
||||
|
||||
# todo turn ip_address string into a number, then fetch the locid and ispid and the other stuff...
|
||||
# turn ip_address string into a number, then fetch the isp and block records
|
||||
|
||||
addr = JamIsp.ip_to_num(ip_address)
|
||||
puts("============= JamIsp.ip_to_num returns #{addr} for #{ip_address} =============")
|
||||
#puts("============= JamIsp.ip_to_num returns #{addr} for #{ip_address} =============")
|
||||
|
||||
isp = JamIsp.lookup(addr)
|
||||
#puts("============= JamIsp.lookup returns #{isp.inspect} for #{addr} =============")
|
||||
if isp.nil? then ispid = 0 else ispid = isp.coid end
|
||||
puts("============= JamIsp.lookup returns #{ispid} for #{addr} =============")
|
||||
|
||||
block = GeoIpBlocks.lookup(addr)
|
||||
#puts("============= GeoIpBlocks.lookup returns #{block.inspect} for #{addr} =============")
|
||||
if block.nil? then locid = 0 else locid = block.locid end
|
||||
puts("============= GeoIpBlocks.lookup returns #{locid} for #{addr} =============")
|
||||
|
||||
locidispid = 0
|
||||
latitude = 0.0
|
||||
longitude = 0.0
|
||||
countrycode = 'US'
|
||||
region = 'TX'
|
||||
city = 'Austin'
|
||||
location = GeoIpLocations.lookup(locid)
|
||||
if location.nil?
|
||||
locidispid = 0
|
||||
latitude = 0.0
|
||||
longitude = 0.0
|
||||
countrycode = 'US'
|
||||
region = 'TX'
|
||||
city = 'Austin'
|
||||
else
|
||||
locidispid = locid*1000000+ispid
|
||||
latitude = location.latitude
|
||||
longitude = location.longitude
|
||||
countrycode = location.countrycode
|
||||
region = location.region
|
||||
city = location.city
|
||||
end
|
||||
|
||||
lock_connections(conn)
|
||||
|
||||
conn.exec("INSERT INTO connections (user_id, client_id, addr, locidispid, latitude, longitude, countrycode, region, city, aasm_state) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)",
|
||||
[user_id, client_id, addr, locidispid, latitude, longitude, countrycode, region, city, Connection::CONNECT_STATE.to_s]).clear
|
||||
conn.exec("INSERT INTO connections (user_id, client_id, addr, locidispid, latitude, longitude, countrycode, region, city, aasm_state, ip_address) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)",
|
||||
[user_id, client_id, addr, locidispid, latitude, longitude, countrycode, region, city, Connection::CONNECT_STATE.to_s, ip_address]).clear
|
||||
|
||||
# we just created a new connection-if this is the first time the user has shown up, we need to send out a message to his friends
|
||||
conn.exec("SELECT count(user_id) FROM connections WHERE user_id = $1", [user_id]) do |result|
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ module JamRuby
|
|||
validates_uniqueness_of :user_id, :scope => :recording_id
|
||||
validate :user_belongs_to_recording
|
||||
|
||||
|
||||
before_create :generate_share_token
|
||||
|
||||
SHARE_TOKEN_LENGTH = 8
|
||||
|
|
@ -67,7 +68,6 @@ module JamRuby
|
|||
!ClaimedRecording.find_by_user_id_and_recording_id(some_user.id, recording_id).nil?
|
||||
end
|
||||
|
||||
|
||||
def remove_non_alpha_num(token)
|
||||
token.gsub(/[^0-9A-Za-z]/, '')
|
||||
end
|
||||
|
|
|
|||
|
|
@ -4,17 +4,14 @@ module JamRuby
|
|||
self.table_name = 'geoipblocks'
|
||||
|
||||
def self.lookup(ipnum)
|
||||
GeoIpBlocks.select(:locid)
|
||||
.where('geom && ST_MakePoint(?, 0) AND ? BETWEEN beginip AND endip', ipnum, ipnum)
|
||||
GeoIpBlocks.where('geom && ST_MakePoint(?, 0) AND ? BETWEEN beginip AND endip', ipnum, ipnum)
|
||||
.limit(1)
|
||||
.first
|
||||
end
|
||||
|
||||
def self.make_row(beginip, endip, locid)
|
||||
c = ActiveRecord::Base.connection.raw_connection
|
||||
c.prepare('blah', 'insert into geoipblocks (beginip, endip, locid, geom) values($1::bigint, $2::bigint, $3, ST_MakeEnvelope($1::bigint, -1, $2::bigint, 1))')
|
||||
c.exec_prepared('blah', [beginip, endip, locid])
|
||||
c.exec("deallocate blah")
|
||||
def self.createx(beginip, endip, locid)
|
||||
c = connection.raw_connection
|
||||
c.exec_params('insert into geoipblocks (beginip, endip, locid, geom) values($1::bigint, $2::bigint, $3, ST_MakeEnvelope($1::bigint, -1, $2::bigint, 1))', [beginip, endip, locid])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,18 @@
|
|||
module JamRuby
|
||||
class GeoIpLocations < ActiveRecord::Base
|
||||
|
||||
self.table_name = 'geoiplocations'
|
||||
|
||||
def self.lookup(locid)
|
||||
GeoIpLocations.where(locid: locid)
|
||||
.limit(1)
|
||||
.first
|
||||
end
|
||||
|
||||
def self.createx(locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode)
|
||||
c = connection.raw_connection
|
||||
c.exec_params('insert into geoiplocations (locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode, geog) values($1, $2, $3, $4, $5, $6, $7, $8, $9, ST_SetSRID(ST_MakePoint($7, $6), 4326)::geography)',
|
||||
[locid, countrycode, region, city, postalcode, latitude, longitude, metrocode, areacode])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -18,11 +18,10 @@ module JamRuby
|
|||
.first
|
||||
end
|
||||
|
||||
def self.make_row(beginip, endip, coid)
|
||||
c = ActiveRecord::Base.connection.raw_connection
|
||||
c.prepare('blah', 'insert into jamisp (beginip, endip, coid, geom) values($1::bigint, $2::bigint, $3, ST_MakeEnvelope($1::bigint, -1, $2::bigint, 1))')
|
||||
c.exec_prepared('blah', [beginip, endip, coid])
|
||||
c.exec("deallocate blah")
|
||||
def self.createx(beginip, endip, coid)
|
||||
c = connection.raw_connection
|
||||
c.exec_params('insert into jamisp (beginip, endip, coid, geom) values($1::bigint, $2::bigint, $3, ST_MakeEnvelope($1::bigint, -1, $2::bigint, 1))',
|
||||
[beginip, endip, coid])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -10,14 +10,24 @@ module JamRuby
|
|||
|
||||
attr_accessible :ogg_url, :should_retry, as: :admin
|
||||
attr_accessor :is_skip_mount_uploader
|
||||
attr_writer :current_user
|
||||
|
||||
belongs_to :recording, :class_name => "JamRuby::Recording", :inverse_of => :mixes, :foreign_key => 'recording_id'
|
||||
|
||||
validates :download_count, presence: true
|
||||
validate :verify_download_count
|
||||
|
||||
skip_callback :save, :before, :store_picture!, if: :is_skip_mount_uploader
|
||||
|
||||
mount_uploader :ogg_url, MixUploader
|
||||
|
||||
|
||||
def verify_download_count
|
||||
if (self.download_count < 0 || self.download_count > APP_CONFIG.max_audio_downloads) && !@current_user.admin
|
||||
errors.add(:download_count, "must be less than or equal to 100")
|
||||
end
|
||||
end
|
||||
|
||||
before_validation do
|
||||
# this should be an activeadmin only path, because it's using the mount_uploader (whereas the client does something completely different)
|
||||
if !is_skip_mount_uploader && ogg_url.present? && ogg_url.respond_to?(:file) && ogg_url_changed?
|
||||
|
|
@ -67,7 +77,6 @@ module JamRuby
|
|||
!ClaimedRecording.find_by_user_id_and_recording_id(some_user.id, recording_id).nil?
|
||||
end
|
||||
|
||||
|
||||
def errored(reason, detail)
|
||||
self.error_reason = reason
|
||||
self.error_detail = detail
|
||||
|
|
@ -148,6 +157,11 @@ module JamRuby
|
|||
Mix.construct_filename(self.created_at, self.recording_id, self.id, type)
|
||||
end
|
||||
|
||||
def update_download_count(count=1)
|
||||
self.download_count = self.download_count + count
|
||||
self.last_downloaded_at = Time.now
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def delete_s3_files
|
||||
|
|
|
|||
|
|
@ -173,8 +173,6 @@ module JamRuby
|
|||
|
||||
hist.end_history if hist
|
||||
|
||||
puts "**************NOTIFICATION SESSION ENDED**************"
|
||||
|
||||
Notification.send_session_ended(session_id)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -357,7 +357,6 @@ module JamRuby
|
|||
# publish to all users who have a notification for this session
|
||||
# TODO: do this in BULK or in async block
|
||||
notifications.each do |n|
|
||||
puts "*************SENDING SESSION_ENDED TO #{n.target_user_id}***************"
|
||||
msg = @@message_factory.session_ended(n.target_user_id, session_id)
|
||||
@@mq_router.publish_to_user(n.target_user_id, msg)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ module JamRuby
|
|||
attr_writer :is_skip_mount_uploader
|
||||
|
||||
attr_accessible :discard, :user, :user_id, :instrument_id, :sound, :client_id, :track_id, :client_track_id, :url, as: :admin
|
||||
attr_writer :current_user
|
||||
|
||||
SOUND = %w(mono stereo)
|
||||
MAX_PART_FAILURES = 3
|
||||
|
|
@ -31,11 +32,13 @@ module JamRuby
|
|||
validates :length, length: {minimum: 1, maximum: 1024 * 1024 * 256 }, if: :upload_starting? # 256 megs max. is this reasonable? surely...
|
||||
validates :user, presence: true
|
||||
validates :instrument, presence: true
|
||||
validates :download_count, presence: true
|
||||
|
||||
before_destroy :delete_s3_files
|
||||
validate :validate_fully_uploaded
|
||||
validate :validate_part_complete
|
||||
validate :validate_too_many_upload_failures
|
||||
validate :verify_download_count
|
||||
|
||||
before_save :sanitize_active_admin
|
||||
skip_callback :save, :before, :store_picture!, if: :is_skip_mount_uploader?
|
||||
|
|
@ -97,6 +100,12 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def verify_download_count
|
||||
if (self.download_count < 0 || self.download_count > APP_CONFIG.max_audio_downloads) && !@current_user.admin
|
||||
errors.add(:download_count, "must be less than or equal to 100")
|
||||
end
|
||||
end
|
||||
|
||||
def sanitize_active_admin
|
||||
self.user_id = nil if self.user_id == ''
|
||||
end
|
||||
|
|
@ -187,6 +196,11 @@ module JamRuby
|
|||
RecordedTrack.construct_filename(self.created_at, self.recording.id, self.client_track_id)
|
||||
end
|
||||
|
||||
def update_download_count(count=1)
|
||||
self.download_count = self.download_count + count
|
||||
self.last_downloaded_at = Time.now
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def delete_s3_files
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
require 'ipaddr'
|
||||
|
||||
module JamRuby
|
||||
class Score < ActiveRecord::Base
|
||||
|
||||
self.table_name = 'scores'
|
||||
|
||||
default_scope order('score_dt desc')
|
||||
|
||||
def self.createx(alocidispid, anodeid, aaddr, blocidispid, bnodeid, baddr, score, score_dt)
|
||||
score_dt = Time.new.utc if score_dt.nil?
|
||||
Score.create(alocidispid: alocidispid, anodeid: anodeid, aaddr: aaddr, blocidispid: blocidispid, bnodeid: bnodeid, baddr: baddr, score: score, scorer: 0, score_dt: score_dt)
|
||||
Score.create(alocidispid: blocidispid, anodeid: bnodeid, aaddr: baddr, blocidispid: alocidispid, bnodeid: anodeid, baddr: aaddr, score: score, scorer: 1, score_dt: score_dt) if alocidispid != blocidispid
|
||||
end
|
||||
|
||||
def self.deletex(alocidispid, blocidispid)
|
||||
Score.where(alocidispid: alocidispid, blocidispid: blocidispid).delete_all
|
||||
Score.where(alocidispid: blocidispid, blocidispid: alocidispid).delete_all if alocidispid != blocidispid
|
||||
end
|
||||
|
||||
def self.findx(alocidispid, blocidispid)
|
||||
s = Score.where(alocidispid: alocidispid, blocidispid: blocidispid).first
|
||||
return -1 if s.nil?
|
||||
return s.score
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -171,10 +171,28 @@ FactoryGirl.define do
|
|||
association :user, factory: :user
|
||||
|
||||
before(:create) { |claimed_recording|
|
||||
|
||||
claimed_recording.recording = FactoryGirl.create(:recording_with_track, owner: claimed_recording.user) unless claimed_recording.recording
|
||||
}
|
||||
|
||||
|
||||
end
|
||||
|
||||
factory :mix, :class => JamRuby::Mix do
|
||||
started_at Time.now
|
||||
completed_at Time.now
|
||||
ogg_md5 'abc'
|
||||
ogg_length 1
|
||||
sequence(:ogg_url) { |n| "recordings/ogg/#{n}" }
|
||||
mp3_md5 'abc'
|
||||
mp3_length 1
|
||||
sequence(:mp3_url) { |n| "recordings/mp3/#{n}" }
|
||||
completed true
|
||||
|
||||
before(:create) {|mix|
|
||||
user = FactoryGirl.create(:user)
|
||||
mix.recording = FactoryGirl.create(:recording_with_track, owner: user)
|
||||
mix.recording.claimed_recordings << FactoryGirl.create(:claimed_recording, user: user, recording: mix.recording)
|
||||
}
|
||||
end
|
||||
|
||||
factory :musician_instrument, :class => JamRuby::MusicianInstrument do
|
||||
|
|
|
|||
|
|
@ -4,16 +4,22 @@ describe GeoIpBlocks do
|
|||
|
||||
before do
|
||||
GeoIpBlocks.delete_all
|
||||
GeoIpBlocks.make_row(0x00000000, 0xffffffff, 17192)
|
||||
GeoIpBlocks.createx(0x01020300, 0x010203ff, 1)
|
||||
GeoIpBlocks.createx(0x02030400, 0x020304ff, 2)
|
||||
end
|
||||
|
||||
it "count" do GeoIpBlocks.count.should == 1 end
|
||||
after do
|
||||
GeoIpBlocks.delete_all
|
||||
GeoIpBlocks.createx(0x00000000, 0xffffffff, 17192)
|
||||
end
|
||||
|
||||
it "count" do GeoIpBlocks.count.should == 2 end
|
||||
|
||||
let(:first) { GeoIpBlocks.lookup(0x01020304) }
|
||||
let(:second) { GeoIpBlocks.lookup(0x02030405) }
|
||||
let(:seventh) { GeoIpBlocks.lookup(9999999999) } # bogus
|
||||
let(:third) { GeoIpBlocks.lookup(9999999999) } # bogus
|
||||
|
||||
it "first.locid" do first.locid.should == 17192 end
|
||||
it "second.locid" do second.locid.should == 17192 end
|
||||
it "seventh" do seventh.should be_nil end
|
||||
it "first.locid" do first.locid.should == 1 end
|
||||
it "second.locid" do second.locid.should == 2 end
|
||||
it "third" do third.should be_nil end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GeoIpLocations do
|
||||
|
||||
before do
|
||||
GeoIpLocations.delete_all
|
||||
GeoIpLocations.createx(17192, 'US', 'TX', 'Austin', '78749', 30.2076, -97.8587, 635, '512')
|
||||
GeoIpLocations.createx(48086, 'MX', '28', 'Matamoros', '', 25.8833, -97.5000, nil, '')
|
||||
end
|
||||
|
||||
it "count" do GeoIpLocations.count.should == 2 end
|
||||
|
||||
let(:first) { GeoIpLocations.lookup(17192) }
|
||||
let(:second) { GeoIpLocations.lookup(48086) }
|
||||
let(:third) { GeoIpLocations.lookup(999999) } # bogus
|
||||
|
||||
it "first" do
|
||||
first.locid.should == 17192
|
||||
first.countrycode.should eql('US')
|
||||
first.region.should eql('TX')
|
||||
first.city.should eql('Austin')
|
||||
first.latitude.should == 30.2076
|
||||
first.longitude.should == -97.8587
|
||||
end
|
||||
|
||||
it "second" do
|
||||
second.locid.should == 48086
|
||||
second.countrycode.should eql('MX')
|
||||
second.region.should eql('28')
|
||||
second.city.should eql('Matamoros')
|
||||
second.latitude.should == 25.8833
|
||||
second.longitude.should == -97.5000
|
||||
end
|
||||
|
||||
it "third" do third.should be_nil end
|
||||
end
|
||||
|
|
@ -4,17 +4,17 @@ describe JamIsp do
|
|||
|
||||
before do
|
||||
JamIsp.delete_all
|
||||
JamIsp.make_row(0x01020300, 0x010203ff, 1)
|
||||
JamIsp.make_row(0x02030400, 0x020304ff, 2)
|
||||
JamIsp.make_row(0x03040500, 0x030405ff, 3)
|
||||
JamIsp.make_row(0x04050600, 0x040506ff, 4)
|
||||
JamIsp.make_row(0xc0A80100, 0xc0A801ff, 5)
|
||||
JamIsp.make_row(0xfffefd00, 0xfffefdff, 6)
|
||||
JamIsp.createx(0x01020300, 0x010203ff, 1)
|
||||
JamIsp.createx(0x02030400, 0x020304ff, 2)
|
||||
JamIsp.createx(0x03040500, 0x030405ff, 3)
|
||||
JamIsp.createx(0x04050600, 0x040506ff, 4)
|
||||
JamIsp.createx(0xc0A80100, 0xc0A801ff, 5)
|
||||
JamIsp.createx(0xfffefd00, 0xfffefdff, 6)
|
||||
end
|
||||
|
||||
after do
|
||||
JamIsp.delete_all
|
||||
JamIsp.make_row(0x00000000, 0xffffffff, 1)
|
||||
JamIsp.createx(0x00000000, 0xffffffff, 1)
|
||||
end
|
||||
|
||||
it "count" do JamIsp.count.should == 6 end
|
||||
|
|
|
|||
|
|
@ -63,6 +63,16 @@ describe Mix do
|
|||
recordings.length.should == 0
|
||||
end
|
||||
|
||||
|
||||
describe "download count" do
|
||||
it "will fail if too high" do
|
||||
mix = FactoryGirl.create(:mix)
|
||||
mix.current_user = mix.recording.owner
|
||||
mix.update_download_count(APP_CONFIG.max_audio_downloads + 1)
|
||||
mix.save
|
||||
mix.errors[:download_count].should == ["must be less than or equal to 100"]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Score do
|
||||
|
||||
before do
|
||||
Score.delete_all
|
||||
Score.createx(1234, 'anodeid', 0x01020304, 2345, 'bnodeid', 0x02030405, 20, nil)
|
||||
Score.createx(1234, 'anodeid', 0x01020304, 3456, 'cnodeid', 0x03040506, 30, nil)
|
||||
Score.createx(1234, 'anodeid', 0x01020304, 3456, 'cnodeid', 0x03040506, 40, Time.new.utc-3600)
|
||||
end
|
||||
|
||||
it "count" do
|
||||
Score.count.should == 6
|
||||
end
|
||||
|
||||
it 'a to b' do
|
||||
s = Score.where(alocidispid: 1234, blocidispid: 2345).limit(1).first
|
||||
s.should_not be_nil
|
||||
s.alocidispid.should == 1234
|
||||
s.anodeid.should eql('anodeid')
|
||||
s.aaddr.should == 0x01020304
|
||||
s.blocidispid.should == 2345
|
||||
s.bnodeid.should eql('bnodeid')
|
||||
s.baddr.should == 0x02030405
|
||||
s.score.should == 20
|
||||
s.scorer.should == 0
|
||||
s.score_dt.should_not be_nil
|
||||
end
|
||||
|
||||
it 'b to a' do
|
||||
s = Score.where(alocidispid: 2345, blocidispid: 1234).limit(1).first
|
||||
s.should_not be_nil
|
||||
s.alocidispid.should == 2345
|
||||
s.anodeid.should eql('bnodeid')
|
||||
s.aaddr.should == 0x02030405
|
||||
s.blocidispid.should == 1234
|
||||
s.bnodeid.should eql('anodeid')
|
||||
s.baddr.should == 0x01020304
|
||||
s.score.should == 20
|
||||
s.scorer.should == 1
|
||||
s.score_dt.should_not be_nil
|
||||
end
|
||||
|
||||
it 'a to c' do
|
||||
s = Score.where(alocidispid: 1234, blocidispid: 3456).limit(1).first
|
||||
s.should_not be_nil
|
||||
s.alocidispid.should == 1234
|
||||
s.anodeid.should eql('anodeid')
|
||||
s.aaddr.should == 0x01020304
|
||||
s.blocidispid.should == 3456
|
||||
s.bnodeid.should eql('cnodeid')
|
||||
s.baddr.should == 0x03040506
|
||||
s.score.should == 30
|
||||
s.scorer.should == 0
|
||||
s.score_dt.should_not be_nil
|
||||
end
|
||||
|
||||
it 'c to a' do
|
||||
s = Score.where(alocidispid: 3456, blocidispid: 1234).limit(1).first
|
||||
s.should_not be_nil
|
||||
s.alocidispid.should == 3456
|
||||
s.anodeid.should eql('cnodeid')
|
||||
s.aaddr.should == 0x03040506
|
||||
s.blocidispid.should == 1234
|
||||
s.bnodeid.should eql('anodeid')
|
||||
s.baddr.should == 0x01020304
|
||||
s.score.should == 30
|
||||
s.scorer.should == 1
|
||||
s.score_dt.should_not be_nil
|
||||
end
|
||||
|
||||
it 'delete a to c' do
|
||||
Score.deletex(1234, 3456)
|
||||
Score.count.should == 2
|
||||
Score.where(alocidispid: 1234, blocidispid: 3456).limit(1).first.should be_nil
|
||||
Score.where(alocidispid: 3456, blocidispid: 1234).limit(1).first.should be_nil
|
||||
Score.where(alocidispid: 1234, blocidispid: 2345).limit(1).first.should_not be_nil
|
||||
Score.where(alocidispid: 2345, blocidispid: 1234).limit(1).first.should_not be_nil
|
||||
end
|
||||
|
||||
it 'findx' do
|
||||
Score.findx(1234, 1234).should == -1
|
||||
Score.findx(1234, 2345).should == 20
|
||||
Score.findx(1234, 3456).should == 30
|
||||
|
||||
Score.findx(2345, 1234).should == 20
|
||||
Score.findx(2345, 2345).should == -1
|
||||
Score.findx(2345, 3456).should == -1
|
||||
|
||||
Score.findx(3456, 1234).should == 30
|
||||
Score.findx(3456, 2345).should == -1
|
||||
Score.findx(3456, 3456).should == -1
|
||||
end
|
||||
|
||||
end
|
||||
|
|
@ -13,6 +13,9 @@ SpecDb::recreate_database
|
|||
# initialize ActiveRecord's db connection
|
||||
ActiveRecord::Base.establish_connection(YAML::load(File.open('config/database.yml'))["test"])
|
||||
|
||||
# so jam_ruby models that use APP_CONFIG in metadata will load. this is later stubbed pre test run
|
||||
APP_CONFIG = app_config
|
||||
|
||||
require 'jam_ruby'
|
||||
require 'factory_girl'
|
||||
require 'rubygems'
|
||||
|
|
|
|||
|
|
@ -101,6 +101,10 @@ def app_config
|
|||
'315576000'
|
||||
end
|
||||
|
||||
def max_audio_downloads
|
||||
100
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def audiomixer_workspace_path
|
||||
|
|
|
|||
|
|
@ -209,7 +209,7 @@
|
|||
var password_confirmation_errors = context.JK.format_errors("password_confirmation", errors)
|
||||
|
||||
if(current_password_errors != null) {
|
||||
$('#account-edit-password-form #account-forgot-password').closest('div.field').addClass('error').end().after(current_password_errors);
|
||||
$('#account-edit-password-form input[name=current_password]').closest('div.field').addClass('error').end().after(current_password_errors);
|
||||
}
|
||||
|
||||
if(password_errors != null) {
|
||||
|
|
|
|||
|
|
@ -47,55 +47,53 @@
|
|||
/****************** MAIN PORTION OF SCREEN *****************/
|
||||
|
||||
function addFollowing(isBand, id) {
|
||||
var newFollowing = {};
|
||||
var newFollowing = {};
|
||||
|
||||
if (!isBand) {
|
||||
newFollowing.user_id = id;
|
||||
}
|
||||
else {
|
||||
newFollowing.band_id = id;
|
||||
}
|
||||
if (!isBand) {
|
||||
newFollowing.user_id = id;
|
||||
}
|
||||
else {
|
||||
newFollowing.band_id = id;
|
||||
}
|
||||
|
||||
rest.addFollowing(newFollowing)
|
||||
.done(function() {
|
||||
if (isBand) {
|
||||
var newCount = parseInt($("#band-profile-follower-stats").text()) + 1;
|
||||
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
|
||||
$('#band-profile-follower-stats').html(newCount + text);
|
||||
configureBandFollowingButton(true);
|
||||
}
|
||||
else {
|
||||
configureMemberFollowingButton(true, id);
|
||||
}
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
rest.addFollowing(newFollowing)
|
||||
.done(function() {
|
||||
if (isBand) {
|
||||
var newCount = parseInt($("#band-profile-follower-stats").text()) + 1;
|
||||
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
|
||||
$('#band-profile-follower-stats').html(newCount + text);
|
||||
configureBandFollowingButton(true);
|
||||
}
|
||||
else {
|
||||
configureMemberFollowingButton(true, id);
|
||||
}
|
||||
renderActive();
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
}
|
||||
|
||||
function removeFollowing(isBand, id) {
|
||||
var following = {};
|
||||
following.target_entity_id = id;
|
||||
|
||||
rest.removeFollowing(following)
|
||||
.done(function() {
|
||||
renderActive(); // refresh stats
|
||||
if (isBand) {
|
||||
var newCount = parseInt($("#band-profile-follower-stats").text()) - 1;
|
||||
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
|
||||
$('#band-profile-follower-stats').html(newCount + text);
|
||||
configureBandFollowingButton(false);
|
||||
}
|
||||
else {
|
||||
configureMemberFollowingButton(false, id);
|
||||
}
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
rest.removeFollowing(id)
|
||||
.done(function() {
|
||||
if (isBand) {
|
||||
var newCount = parseInt($("#band-profile-follower-stats").text()) - 1;
|
||||
var text = newCount > 1 || newCount == 0 ? " Followers" : " Follower";
|
||||
$('#band-profile-follower-stats').html(newCount + text);
|
||||
configureBandFollowingButton(false);
|
||||
}
|
||||
else {
|
||||
configureMemberFollowingButton(false, id);
|
||||
}
|
||||
renderActive();
|
||||
})
|
||||
.fail(app.ajaxError);
|
||||
}
|
||||
|
||||
function configureBandFollowingButton(following) {
|
||||
$('#btn-follow-band').unbind("click");
|
||||
|
||||
if (following) {
|
||||
$('#btn-follow-band').text('STOP FOLLOWING');
|
||||
$('#btn-follow-band').text('UNFOLLOW');
|
||||
$('#btn-follow-band').click(function() {
|
||||
removeFollowing(true, bandId);
|
||||
return false;
|
||||
|
|
@ -121,7 +119,7 @@
|
|||
$btnFollowMember.unbind("click");
|
||||
|
||||
if (following) {
|
||||
$btnFollowMember.text('UN-FOLLOW');
|
||||
$btnFollowMember.text('UNFOLLOW');
|
||||
$btnFollowMember.click(function() {
|
||||
removeFollowing(false, userId);
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -487,7 +487,7 @@
|
|||
* Load available drivers and populate the driver select box.
|
||||
*/
|
||||
function loadAudioDrivers() {
|
||||
var drivers = jamClient.FTUEGetDevices();
|
||||
var drivers = jamClient.FTUEGetDevices(false);
|
||||
|
||||
var driverOptionFunc = function (driverKey, index, list) {
|
||||
optionsHtml += '<option title="' + drivers[driverKey] + '"value="' + driverKey + '">' +
|
||||
|
|
|
|||
|
|
@ -49,20 +49,23 @@
|
|||
});
|
||||
|
||||
var bandHtml = context.JK.fillTemplate(template, {
|
||||
avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url),
|
||||
name: response.name,
|
||||
location: response.location,
|
||||
genres: genres.join(', '),
|
||||
musicians: musicianHtml,
|
||||
like_count: response.liker_count,
|
||||
follower_count: response.follower_count,
|
||||
recording_count: response.recording_count,
|
||||
session_count: response.session_count,
|
||||
biography: response.biography,
|
||||
profile_url: "/client#/bandProfile/" + response.id
|
||||
bandId: response.id,
|
||||
avatar_url: context.JK.resolveBandAvatarUrl(response.photo_url),
|
||||
name: response.name,
|
||||
location: response.location,
|
||||
genres: genres.join(', '),
|
||||
musicians: musicianHtml,
|
||||
like_count: response.liker_count,
|
||||
follower_count: response.follower_count,
|
||||
recording_count: response.recording_count,
|
||||
session_count: response.session_count,
|
||||
biography: response.biography,
|
||||
followAction: response.is_following ? "removeBandFollowing" : "addBandFollowing",
|
||||
profile_url: "/client#/bandProfile/" + response.id
|
||||
});
|
||||
|
||||
$(hoverSelector).append('<h2>Band Detail</h2>' + bandHtml);
|
||||
configureActionButtons(response);
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
if(xhr.status >= 500) {
|
||||
|
|
@ -77,6 +80,20 @@
|
|||
});
|
||||
};
|
||||
|
||||
function configureActionButtons(band) {
|
||||
var btnFollowSelector = "#btnFollow";
|
||||
|
||||
// if unauthenticated or authenticated user is viewing his own profile
|
||||
if (!context.JK.currentUserId) {
|
||||
$(btnFollowSelector, hoverSelector).hide();
|
||||
}
|
||||
else {
|
||||
if (band.is_following) {
|
||||
$(btnFollowSelector, hoverSelector).html('UNFOLLOW');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.hideBubble = function() {
|
||||
$(hoverSelector).hide();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -56,12 +56,15 @@
|
|||
location: response.location,
|
||||
friend_count: response.friend_count,
|
||||
follower_count: response.follower_count,
|
||||
friendAction: response.is_friend ? "removeFanFriend" : (response.pending_friend_request ? "" : "sendFanFriendRequest"),
|
||||
followAction: response.is_following ? "removeFanFollowing" : "addFanFollowing",
|
||||
biography: response.biography,
|
||||
followings: response.followings && response.followings.length > 0 ? followingHtml : "<tr><td>N/A</td></tr>",
|
||||
profile_url: "/client#/profile/" + response.id
|
||||
});
|
||||
|
||||
$(hoverSelector).append('<h2>Fan Detail</h2>' + fanHtml);
|
||||
configureActionButtons(response);
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
if(xhr.status >= 500) {
|
||||
|
|
@ -76,6 +79,33 @@
|
|||
});
|
||||
};
|
||||
|
||||
function configureActionButtons(user) {
|
||||
var btnFriendSelector = "#btnFriend";
|
||||
var btnFollowSelector = "#btnFollow";
|
||||
|
||||
if (!context.JK.currentUserId || context.JK.currentUserId === user.id) {
|
||||
$(btnFriendSelector, hoverSelector).hide();
|
||||
$(btnFollowSelector, hoverSelector).hide();
|
||||
}
|
||||
else {
|
||||
if (user.is_friend) {
|
||||
$(btnFriendSelector, hoverSelector).html('DISCONNECT');
|
||||
}
|
||||
|
||||
if (user.is_following) {
|
||||
$(btnFollowSelector, hoverSelector).html('UNFOLLOW');
|
||||
|
||||
$(btnFollowSelector, hoverSelector).click(function(evt) {
|
||||
rest.removeFollowing(user.id);
|
||||
});
|
||||
}
|
||||
|
||||
if (user.pending_friend_request) {
|
||||
$(btnFriendSelector, hoverSelector).hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.hideBubble = function() {
|
||||
$(hoverSelector).hide();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -75,12 +75,15 @@
|
|||
session_count: response.session_count,
|
||||
session_display: sessionDisplayStyle,
|
||||
session_id: sessionId,
|
||||
friendAction: response.is_friend ? "removeMusicianFriend" : (response.pending_friend_request ? "" : "sendMusicianFriendRequest"),
|
||||
followAction: response.is_following ? "removeMusicianFollowing" : "addMusicianFollowing",
|
||||
biography: response.biography,
|
||||
followings: response.followings && response.followings.length > 0 ? followingHtml : "<tr><td>N/A</td></tr>",
|
||||
profile_url: "/client#/profile/" + response.id
|
||||
});
|
||||
|
||||
$(hoverSelector).append('<h2>Musician Detail</h2>' + musicianHtml);
|
||||
configureActionButtons(response);
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
if(xhr.status >= 500) {
|
||||
|
|
@ -95,6 +98,28 @@
|
|||
});
|
||||
};
|
||||
|
||||
function configureActionButtons(user) {
|
||||
var btnFriendSelector = "#btnFriend";
|
||||
var btnFollowSelector = "#btnFollow";
|
||||
|
||||
// if unauthenticated or authenticated user is viewing his own profile
|
||||
if (!context.JK.currentUserId || context.JK.currentUserId === user.id) {
|
||||
$(btnFriendSelector, hoverSelector).hide();
|
||||
$(btnFollowSelector, hoverSelector).hide();
|
||||
}
|
||||
else {
|
||||
if (user.is_friend) {
|
||||
$(btnFriendSelector, hoverSelector).html('DISCONNECT');
|
||||
}
|
||||
if (user.is_following) {
|
||||
$(btnFollowSelector, hoverSelector).html('UNFOLLOW');
|
||||
}
|
||||
if (user.pending_friend_request) {
|
||||
$(btnFriendSelector, hoverSelector).hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.hideBubble = function() {
|
||||
$(hoverSelector).hide();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -55,6 +55,7 @@
|
|||
});
|
||||
|
||||
$(hoverSelector).append('<h2>Recording Detail</h2>' + recordingHtml);
|
||||
toggleActionButtons();
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
if(xhr.status >= 500) {
|
||||
|
|
@ -69,6 +70,13 @@
|
|||
});
|
||||
};
|
||||
|
||||
function toggleActionButtons() {
|
||||
if (!context.JK.currentUserId) {
|
||||
$("#btnLike", hoverSelector).hide();
|
||||
$("#btnShare", hoverSelector).hide();
|
||||
}
|
||||
}
|
||||
|
||||
this.hideBubble = function() {
|
||||
$(hoverSelector).hide();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
});
|
||||
|
||||
$(hoverSelector).append('<h2>Session Detail</h2>' + sessionHtml);
|
||||
toggleActionButtons();
|
||||
})
|
||||
.fail(function(xhr) {
|
||||
if(xhr.status >= 500) {
|
||||
|
|
@ -64,6 +65,13 @@
|
|||
});
|
||||
};
|
||||
|
||||
function toggleActionButtons() {
|
||||
if (!context.JK.currentUserId) {
|
||||
$("#btnLike", hoverSelector).hide();
|
||||
$("#btnShare", hoverSelector).hide();
|
||||
}
|
||||
}
|
||||
|
||||
this.hideBubble = function() {
|
||||
$(hoverSelector).hide();
|
||||
};
|
||||
|
|
|
|||
|
|
@ -451,7 +451,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
function removeLike(options) {
|
||||
function removeLike(likableId, options) {
|
||||
var id = getId(options);
|
||||
return $.ajax({
|
||||
type: "DELETE",
|
||||
|
|
@ -476,15 +476,13 @@
|
|||
});
|
||||
}
|
||||
|
||||
function removeFollowing(options) {
|
||||
function removeFollowing(followableId, options) {
|
||||
var id = getId(options);
|
||||
|
||||
return $.ajax({
|
||||
type: "DELETE",
|
||||
dataType: "json",
|
||||
contentType: 'application/json',
|
||||
url: "/api/users/" + id + "/followings",
|
||||
data: JSON.stringify(options),
|
||||
url: "/api/users/" + id + "/followings/" + followableId,
|
||||
processData: false
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -198,12 +198,13 @@
|
|||
* Generic error handler for Ajax calls.
|
||||
*/
|
||||
function ajaxError(jqXHR, textStatus, errorMessage) {
|
||||
logger.error("Unexpected ajax error: " + textStatus);
|
||||
|
||||
if (jqXHR.status == 404) {
|
||||
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 = 422) {
|
||||
logger.error("Unexpected ajax error: " + textStatus + ", msg: " + errorMessage + ", response: " + jqXHR.responseText);
|
||||
// present a nicer message
|
||||
try {
|
||||
var text = "<ul>";
|
||||
|
|
@ -231,6 +232,7 @@
|
|||
}
|
||||
}
|
||||
else {
|
||||
logger.error("Unexpected ajax error: " + textStatus + ", msg:" + errorMessage);
|
||||
app.notify({title: textStatus, text: errorMessage, detail: jqXHR.responseText});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -500,6 +500,8 @@
|
|||
var accepted = screenEvent(previousScreen, 'beforeHide', data);
|
||||
if(accepted === false) return;
|
||||
|
||||
logger.debug("Changing screen to " + currentScreen);
|
||||
|
||||
screenEvent(currentScreen, 'beforeShow', data);
|
||||
|
||||
// For now -- it seems we want it open always.
|
||||
|
|
|
|||
|
|
@ -193,10 +193,10 @@
|
|||
|
||||
function configureFriendButton() {
|
||||
if (isFriend()) {
|
||||
$('#btn-add-friend').text('REMOVE FRIEND');
|
||||
$('#btn-add-friend').text('DISCONNECT');
|
||||
}
|
||||
else {
|
||||
$('#btn-add-friend').text('ADD FRIEND');
|
||||
$('#btn-add-friend').text('CONNECT');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -213,10 +213,7 @@
|
|||
}
|
||||
|
||||
function removeFollowing(isBand, id) {
|
||||
var following = {};
|
||||
following.target_entity_id = id;
|
||||
|
||||
rest.removeFollowing(following)
|
||||
rest.removeFollowing(id)
|
||||
.done(function() {
|
||||
if (!isBand) {
|
||||
updateFollowingCount(-1);
|
||||
|
|
@ -242,7 +239,7 @@
|
|||
function configureFollowingButton() {
|
||||
|
||||
if (isFollowing()) {
|
||||
$('#btn-follow-user').text('STOP FOLLOWING');
|
||||
$('#btn-follow-user').text('UNFOLLOW');
|
||||
}
|
||||
else {
|
||||
$('#btn-follow-user').text('FOLLOW');
|
||||
|
|
|
|||
|
|
@ -117,23 +117,23 @@
|
|||
selector = isSidebar ? '#sidebar-search-results' : '#search-results';
|
||||
$(selector).append(invitationSentHtml);
|
||||
|
||||
// wire up button click handler if search result is not a friend or the current use
|
||||
// wire up button click handler if search result is not a friend or the current user
|
||||
if (isSidebar) {
|
||||
var $sidebar = $('div[layout=sidebar] div[user-id=' + val.id + ']');
|
||||
if (!val.is_friend && val.id !== context.JK.currentUserId) {
|
||||
$sidebar.find('.btn-connect-friend').click(sendFriendRequest);
|
||||
if (val.is_friend || val.pending_friend_request || val.id === context.JK.currentUserId) {
|
||||
// hide the button if the search result is already a friend
|
||||
$sidebar.find('.btn-connect-friend').hide();
|
||||
}
|
||||
else {
|
||||
// hide the button if the search result is already a friend
|
||||
$sidebar.find('.btn-connect-friend').hide();
|
||||
$sidebar.find('.btn-connect-friend').click(sendFriendRequest);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (!val.is_friend && val.id !== context.JK.currentUserId) {
|
||||
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').click(sendFriendRequest);
|
||||
if (val.is_friend || val.pending_friend_request || val.id === context.JK.currentUserId) {
|
||||
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').hide();
|
||||
}
|
||||
else {
|
||||
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').hide();
|
||||
$('div[user-id=' + val.id + ']').find('.btn-connect-friend').click(sendFriendRequest);
|
||||
}
|
||||
}
|
||||
resultDivVisibility(val, isSidebar);
|
||||
|
|
|
|||
|
|
@ -432,6 +432,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
// not leave session but leave screen
|
||||
function beforeLeave(data) {
|
||||
if(promptLeave) {
|
||||
var leaveSessionWarningDialog = new context.JK.LeaveSessionWarningDialog(context.JK.app,
|
||||
|
|
@ -1209,6 +1210,15 @@
|
|||
}
|
||||
}
|
||||
|
||||
function sessionLeave(evt) {
|
||||
evt.preventDefault();
|
||||
|
||||
promptLeave = false;
|
||||
context.window.location = '/client#/home';
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function sessionResync(evt) {
|
||||
evt.preventDefault();
|
||||
var response = context.jamClient.SessionAudioResync();
|
||||
|
|
@ -1388,7 +1398,8 @@
|
|||
}
|
||||
|
||||
function events() {
|
||||
$('#session-resync').on('click', sessionResync);
|
||||
$('#session-leave').on('click', sessionLeave);
|
||||
$('#session-resync').on('click', sessionResync);
|
||||
$('#session-contents').on("click", '[action="delete"]', deleteSession);
|
||||
$('#tracks').on('click', 'div[control="mute"]', toggleMute);
|
||||
$('#recording-start-stop').on('click', startStopRecording);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@
|
|||
deferred
|
||||
.done(function(){
|
||||
logger.debug("calling jamClient.JoinSession");
|
||||
|
||||
if(!alreadyInSession()) {
|
||||
// on temporary disconnect scenarios, a user may already be in a session when they enter this path
|
||||
// so we avoid double counting
|
||||
|
|
@ -198,7 +197,7 @@
|
|||
callback();
|
||||
}
|
||||
},
|
||||
error: ajaxError,
|
||||
error: function(jqXHR) { app.notifyServerError(jqXHR, "Unable to refresh session data") },
|
||||
complete: function() {
|
||||
requestingSessionRefresh = false;
|
||||
if(pendingSessionRefresh) {
|
||||
|
|
@ -301,7 +300,7 @@
|
|||
logger.debug("successfully updated tracks on the server");
|
||||
//refreshCurrentSession();
|
||||
},
|
||||
error: ajaxError
|
||||
error: function(jqXHR) { app.notifyServerError(jqXHR, "Unable to refresh session data") }
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -318,7 +317,7 @@
|
|||
success: function(response) {
|
||||
logger.debug("Successfully updated track info (" + JSON.stringify(data) + ")");
|
||||
},
|
||||
error: ajaxError
|
||||
error: function(jqXHR) { app.notifyServerError(jqXHR, "Unable to refresh session data") }
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -447,10 +446,6 @@
|
|||
}
|
||||
}
|
||||
|
||||
function ajaxError(jqXHR, textStatus, errorMessage) {
|
||||
logger.error("Unexpected ajax error: " + textStatus);
|
||||
}
|
||||
|
||||
// returns a deferred object
|
||||
function findUserBy(finder) {
|
||||
if(finder.clientId) {
|
||||
|
|
|
|||
|
|
@ -12,13 +12,6 @@
|
|||
var entity = null;
|
||||
var remainingCap = 140 - 22 - 1; // 140 tweet max, minus 22 for link size, minus 1 for space
|
||||
|
||||
var textMap = {
|
||||
LIVE_SESSION: "LIVE SESSION",
|
||||
SESSION: "SESSION",
|
||||
RECORDING: "RECORDING",
|
||||
RECORDED: "RECORDED"
|
||||
};
|
||||
|
||||
function showSpinner() {
|
||||
$(dialogId + ' .dialog-inner').hide();
|
||||
var spinner = $('<div class="spinner spinner-large"></div>')
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
@charset "UTF-8";
|
||||
@import "compass/utilities/text/replacement";
|
||||
@import "compass/typography/text/replacement";
|
||||
|
||||
.header {
|
||||
height: 55px;
|
||||
|
|
|
|||
|
|
@ -55,4 +55,8 @@
|
|||
position:absolute;
|
||||
top:3px;
|
||||
right:4px;
|
||||
}
|
||||
|
||||
#btnPlayPause {
|
||||
position: relative;
|
||||
}
|
||||
|
|
@ -16,4 +16,8 @@
|
|||
font-size:15px;
|
||||
color:#cccc00;
|
||||
margin-left:20px;
|
||||
}*/
|
||||
}*/
|
||||
|
||||
#btnPlayPause {
|
||||
position: relative;
|
||||
}
|
||||
|
|
@ -33,8 +33,7 @@ class ApiController < ApplicationController
|
|||
|
||||
def respond_with_model(model, options = {})
|
||||
if model.errors.any?
|
||||
response.status = :unprocessable_entity
|
||||
respond_with model, layout: nil
|
||||
respond_with model, status: :unprocessable_entity, layout: nil
|
||||
else
|
||||
status = options[:new] && options[:new] == true ? 201 : 200
|
||||
redirect_on_success = options[:location]
|
||||
|
|
|
|||
|
|
@ -24,9 +24,18 @@ class ApiMixesController < ApiController
|
|||
|
||||
def download
|
||||
@mix = Mix.find(params[:id])
|
||||
raise PermissionError, "You can only download a mix you didn't claim" unless @mix.can_download? current_user
|
||||
raise PermissionError, "You can only download a mix you have claimed" unless @mix.can_download? current_user
|
||||
|
||||
redirect_to @mix.sign_url
|
||||
@mix.current_user = current_user
|
||||
@mix.update_download_count
|
||||
|
||||
@mix.valid?
|
||||
if !@mix.errors.any?
|
||||
@mix.save!
|
||||
redirect_to @mix.sign_url
|
||||
else
|
||||
render :json => { :message => "download limit surpassed" }, :status => 404
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
|
|
@ -38,7 +38,18 @@ class ApiRecordingsController < ApiController
|
|||
def download
|
||||
raise PermissionError, ValidationMessages::PERMISSION_VALIDATION_ERROR unless @recorded_track.can_download?(current_user)
|
||||
|
||||
redirect_to @recorded_track.sign_url
|
||||
@recorded_track.current_user = current_user
|
||||
@recorded_track.update_download_count
|
||||
|
||||
@recorded_track.valid?
|
||||
if !@recorded_track.errors.any?
|
||||
@recorded_track.save!
|
||||
redirect_to @recorded_track.sign_url
|
||||
else
|
||||
render :json => { :message => "download limit surpassed" }, :status => 404
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def start
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class ApiUsersController < ApiController
|
||||
|
||||
before_filter :api_signed_in_user, :except => [:create, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring]
|
||||
before_filter :api_signed_in_user, :except => [:create, :show, :signup_confirm, :auth_session_create, :complete, :finalize_update_email, :isp_scoring]
|
||||
before_filter :auth_user, :only => [:session_settings_show, :session_history_index, :session_user_history_index, :update, :delete,
|
||||
:liking_create, :liking_destroy, # likes
|
||||
:following_create, :following_show, :following_destroy, # followings
|
||||
|
|
@ -202,7 +202,7 @@ class ApiUsersController < ApiController
|
|||
end
|
||||
|
||||
def liking_destroy
|
||||
User.delete_liking(params[:id], params[:target_entity_id])
|
||||
User.delete_liking(params[:id], params[:likable_id])
|
||||
respond_with responder: ApiResponder, :status => 204
|
||||
end
|
||||
|
||||
|
|
@ -230,7 +230,7 @@ class ApiUsersController < ApiController
|
|||
end
|
||||
|
||||
def following_destroy
|
||||
User.delete_following(params[:id], params[:target_entity_id])
|
||||
User.delete_following(params[:id], params[:followable_id])
|
||||
respond_with responder: ApiResponder, :status => 204
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
object @mix
|
||||
|
|
@ -23,14 +23,15 @@ if @search.musicians_text_search?
|
|||
musician.friends?(current_user)
|
||||
end
|
||||
|
||||
node :pending_friend_request do |musician|
|
||||
musician.pending_friend_request?(current_user)
|
||||
end
|
||||
|
||||
child :musician_instruments => :instruments do
|
||||
attributes :instrument_id, :description, :proficiency_level, :priority
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
if @search.musicians_filter_search?
|
||||
|
||||
node :city do |user|
|
||||
current_user.try(:location)
|
||||
end
|
||||
|
|
@ -50,6 +51,10 @@ if @search.musicians_filter_search?
|
|||
@search.is_follower?(musician)
|
||||
end
|
||||
|
||||
node :pending_friend_request do |musician|
|
||||
musician.pending_friend_request?(current_user)
|
||||
end
|
||||
|
||||
node :biography do |musician|
|
||||
musician.biography.nil? ? "" : musician.biography
|
||||
end
|
||||
|
|
@ -112,6 +117,10 @@ if @search.fans_text_search?
|
|||
node :is_friend do |fan|
|
||||
fan.friends?(current_user)
|
||||
end
|
||||
|
||||
node :pending_friend_request do |fan|
|
||||
fan.pending_friend_request?(current_user)
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<!-- Account Summary Dialog -->
|
||||
<div layout="screen" layout-id="account/identity" class="screen secondary">
|
||||
<div layout="screen" layout-id="account/identity" class="screen secondary" id="account-identity">
|
||||
<!-- header -->
|
||||
<div class="content-head">
|
||||
<!-- icon -->
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
<span id="alert-message"></span>
|
||||
<br clear="left" /><br />
|
||||
<div class="left">
|
||||
<a id="btn-alert-cancel" class="button-orange">CANCEL</a>
|
||||
<a id="btn-alert-cancel" class="button-grey">CANCEL</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a id="btn-alert-ok" class="button-orange"></a>
|
||||
|
|
|
|||
|
|
@ -5,25 +5,49 @@
|
|||
<script type="text/javascript">
|
||||
var rest = JK.Rest();
|
||||
|
||||
function addLike(bandId) {
|
||||
rest.addLike({band_id: bandId})
|
||||
// function addLike(bandId) {
|
||||
// rest.addLike({band_id: bandId})
|
||||
// .done(function(response) {
|
||||
// $("#spnLikeCount", "#band-hover").html(parseInt($("#spnLikeCount", "#band-hover").text()) + 1);
|
||||
// var $btnLikeSelector = $("#btnLike", "#band-hover");
|
||||
// $btnLikeSelector.unbind("click");
|
||||
// $btnLikeSelector.html("LIKED");
|
||||
// });
|
||||
// }
|
||||
|
||||
function addBandFollowing(bandId) {
|
||||
rest.addFollowing({band_id: bandId})
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount", "#band-hover").html(parseInt($("#spnLikeCount", "#band-hover").text()) + 1);
|
||||
var $btnLikeSelector = $("#btnLike", "#band-hover");
|
||||
$btnLikeSelector.unbind("click");
|
||||
$btnLikeSelector.html("LIKED");
|
||||
adjustBandFollowingCount(1);
|
||||
|
||||
var $btnFollowSelector = $("#btnFollow", "#band-hover");
|
||||
$btnFollowSelector.unbind('click');
|
||||
$btnFollowSelector.attr('onclick', '');
|
||||
$btnFollowSelector.click(function() {
|
||||
removeBandFollowing(bandId);
|
||||
});
|
||||
$btnFollowSelector.html("UNFOLLOW");
|
||||
});
|
||||
}
|
||||
|
||||
function addFollowing(bandId) {
|
||||
rest.addFollowing({band_id: bandId})
|
||||
function removeBandFollowing(bandId) {
|
||||
rest.removeFollowing(bandId)
|
||||
.done(function(response) {
|
||||
$("#spnFollowCount", "#band-hover").html(parseInt($("#spnFollowCount", "#band-hover").text()) + 1);
|
||||
var $btnFollowSelector = $("#btnFollow", "#band-hover");
|
||||
$btnFollowSelector.unbind("click");
|
||||
$btnFollowSelector.html("STOP FOLLOWING");
|
||||
adjustBandFollowingCount(-1);
|
||||
|
||||
var $btnFollowSelector = $("#btnFollow", "#band-hover");
|
||||
$btnFollowSelector.unbind('click');
|
||||
$btnFollowSelector.attr('onclick', '');
|
||||
$btnFollowSelector.click(function() {
|
||||
addBandFollowing(bandId);
|
||||
});
|
||||
$btnFollowSelector.html("FOLLOW");
|
||||
});
|
||||
}
|
||||
|
||||
function adjustBandFollowingCount(value) {
|
||||
$("#spnFollowCount", "#band-hover").text(parseInt($("#spnFollowCount", "#band-hover").text()) + value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="template-hover-band">
|
||||
|
|
@ -33,7 +57,6 @@
|
|||
<h3>{name}</h3>
|
||||
<small>{location}<br /><strong>{genres}</strong></small><br />
|
||||
<br clear="all" />
|
||||
<span id="spnLikeCount">{like_count}</span> <img src="/assets/content/icon_like.png" align="absmiddle" />
|
||||
<span id="spnFollowCount">{follower_count}</span> <img src="/assets/content/icon_followers.png" width="22" height="12" align="absmiddle" />
|
||||
{recording_count} <img src="/assets/content/icon_recordings.png" width="12" height="13" align="absmiddle" />
|
||||
{session_count} <img src="/assets/content/icon_session_tiny.png" width="12" height="12" align="absmiddle" />
|
||||
|
|
@ -47,8 +70,8 @@
|
|||
<br />
|
||||
<div align="center">
|
||||
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
|
||||
<div class="left"><a class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a class="button-orange">FOLLOW</a></div>
|
||||
<div class="left" style="display:none;"><a class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnFollow" onclick="{followAction}('{bandId}');" class="button-orange">FOLLOW</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,19 +5,58 @@
|
|||
<script type="text/javascript">
|
||||
var rest = JK.Rest();
|
||||
|
||||
function addFollowing(userId) {
|
||||
function addFanFollowing(userId) {
|
||||
rest.addFollowing({user_id: userId})
|
||||
.done(function(response) {
|
||||
$("#spnFollowCount", "#fan-hover").html(parseInt($("#spnFollowCount", "#fan-hover").text()) + 1);
|
||||
var $btnFollowSelector = $("#btnFollow", "#fan-hover");
|
||||
$btnFollowSelector.unbind("click");
|
||||
$btnFollowSelector.html("STOP FOLLOWING");
|
||||
adjustFanFollowingCount(1);
|
||||
|
||||
var $btnFollowSelector = $("#btnFollow", "#fan-hover");
|
||||
$btnFollowSelector.unbind('click');
|
||||
$btnFollowSelector.attr('onclick', '');
|
||||
$btnFollowSelector.click(function() {
|
||||
removeFanFollowing(userId);
|
||||
});
|
||||
$btnFollowSelector.html("UNFOLLOW");
|
||||
});
|
||||
}
|
||||
|
||||
function sendFriendRequest(userId) {
|
||||
rest.sendFriendRequest(JK.app, userId);
|
||||
function removeFanFollowing(userId) {
|
||||
rest.removeFollowing(userId)
|
||||
.done(function(response) {
|
||||
adjustFanFollowingCount(-1);
|
||||
|
||||
var $btnFollowSelector = $("#btnFollow", "#fan-hover");
|
||||
$btnFollowSelector.unbind('click');
|
||||
$btnFollowSelector.attr('onclick', '');
|
||||
$btnFollowSelector.click(function() {
|
||||
addFanFollowing(userId);
|
||||
});
|
||||
$btnFollowSelector.html("FOLLOW");
|
||||
});
|
||||
}
|
||||
|
||||
function adjustFanFollowingCount(value) {
|
||||
$("#spnFollowCount", "#fan-hover").text(parseInt($("#spnFollowCount", "#fan-hover").text()) + value);
|
||||
}
|
||||
|
||||
function sendFanFriendRequest(userId) {
|
||||
rest.sendFriendRequest(JK.app, userId);
|
||||
$("#btnFriend", "#fan-hover").hide();
|
||||
}
|
||||
|
||||
function removeFanFriend(userId) {
|
||||
rest.removeFriend({friend_id: userId})
|
||||
.done(function() {
|
||||
var $btnFriendSelector = $("#btnFriend", "#fan-hover");
|
||||
$btnFriendSelector.unbind("click");
|
||||
$btnFriendSelector.attr('onclick', '');
|
||||
$btnFriendSelector.html("CONNECT");
|
||||
$btnFriendSelector.click(function() {
|
||||
sendFanFriendRequest(userId);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<script type="text/template" id="template-hover-fan">
|
||||
|
|
@ -38,8 +77,8 @@
|
|||
<br />
|
||||
<div align="center">
|
||||
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
|
||||
<div class="left"><a id="btnFriend" onclick="sendFriendRequest('{userId}');" class="button-orange">FRIEND</a></div>
|
||||
<div class="left"><a id="btnFollow" onclick="addFollowing('{userId}');" class="button-orange">FOLLOW</a></div>
|
||||
<div class="left"><a id="btnFriend" onclick="{friendAction}('{userId}');" class="button-orange">CONNECT</a></div>
|
||||
<div class="left"><a id="btnFollow" onclick="{followAction}('{userId}');" class="button-orange">FOLLOW</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -5,28 +5,66 @@
|
|||
<script type="text/javascript">
|
||||
var rest = JK.Rest();
|
||||
|
||||
function addLike(userId) {
|
||||
rest.addLike({user_id: userId})
|
||||
.done(function(response) {
|
||||
$("#spnLikeCount", "#musician-hover").html(parseInt($("#spnLikeCount", "#musician-hover").text()) + 1);
|
||||
var $btnLikeSelector = $("#btnLike", "#musician-hover");
|
||||
$btnLikeSelector.unbind("click");
|
||||
$btnLikeSelector.html("LIKED");
|
||||
});
|
||||
}
|
||||
// function addLike(userId) {
|
||||
// rest.addLike({user_id: userId})
|
||||
// .done(function(response) {
|
||||
// $("#spnLikeCount", "#musician-hover").text(parseInt($("#spnLikeCount", "#musician-hover").text()) + 1);
|
||||
// var $btnLikeSelector = $("#btnLike", "#musician-hover");
|
||||
// $btnLikeSelector.unbind("click");
|
||||
// $btnLikeSelector.html("LIKED");
|
||||
// });
|
||||
// }
|
||||
|
||||
function addFollowing(userId) {
|
||||
function addMusicianFollowing(userId) {
|
||||
rest.addFollowing({user_id: userId})
|
||||
.done(function(response) {
|
||||
$("#spnFollowCount", "#musician-hover").html(parseInt($("#spnFollowCount", "#musician-hover").text()) + 1);
|
||||
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
|
||||
$btnFollowSelector.unbind("click");
|
||||
$btnFollowSelector.html("UNFOLLOW");
|
||||
adjustMusicianFollowingCount(1);
|
||||
|
||||
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
|
||||
$btnFollowSelector.unbind('click');
|
||||
$btnFollowSelector.attr('onclick', '');
|
||||
$btnFollowSelector.click(function() {
|
||||
removeMusicianFollowing(userId);
|
||||
});
|
||||
$btnFollowSelector.html("UNFOLLOW");
|
||||
});
|
||||
}
|
||||
|
||||
function sendFriendRequest(userId) {
|
||||
function removeMusicianFollowing(userId) {
|
||||
rest.removeFollowing(userId)
|
||||
.done(function(response) {
|
||||
adjustMusicianFollowingCount(-1);
|
||||
|
||||
var $btnFollowSelector = $("#btnFollow", "#musician-hover");
|
||||
$btnFollowSelector.unbind('click');
|
||||
$btnFollowSelector.attr('onclick', '');
|
||||
$btnFollowSelector.click(function() {
|
||||
addMusicianFollowing(userId);
|
||||
});
|
||||
$btnFollowSelector.html("FOLLOW");
|
||||
});
|
||||
}
|
||||
|
||||
function adjustMusicianFollowingCount(value) {
|
||||
$("#spnFollowCount", "#musician-hover").html(parseInt($("#spnFollowCount", "#musician-hover").html()) + value);
|
||||
}
|
||||
|
||||
function sendMusicianFriendRequest(userId) {
|
||||
rest.sendFriendRequest(JK.app, userId);
|
||||
$("#btnFriend", "#musician-hover").hide();
|
||||
}
|
||||
|
||||
function removeMusicianFriend(userId) {
|
||||
rest.removeFriend({friend_id: userId})
|
||||
.done(function() {
|
||||
var $btnFriendSelector = $("#btnFriend", "#musician-hover");
|
||||
$btnFriendSelector.unbind("click");
|
||||
$btnFriendSelector.attr('onclick', '');
|
||||
$btnFriendSelector.html("CONNECT");
|
||||
$btnFriendSelector.click(function() {
|
||||
sendMusicianFriendRequest(userId);
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
@ -54,9 +92,9 @@
|
|||
<br />
|
||||
<div align="center">
|
||||
<div class="left"><a href="{profile_url}" class="button-orange">PROFILE</a></div>
|
||||
<div class="left"><a id="btnLike" onclick="addLike('{userId}');" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnFriend" onclick="sendFriendRequest('{userId}');" class="button-orange">FRIEND</a></div>
|
||||
<div class="left"><a id="btnFollow" onclick="addFollowing('{userId}');" class="button-orange">FOLLOW</a></div>
|
||||
<div class="left" style="display:none;"><a id="btnLike" onclick="addLike('{userId}');" class="button-orange">LIKE</a></div>
|
||||
<div class="left"><a id="btnFriend" onclick="{friendAction}('{userId}');" class="button-orange">CONNECT</a></div>
|
||||
<div class="left"><a id="btnFollow" onclick="{followAction}('{userId}');" class="button-orange">FOLLOW</a></div>
|
||||
</div>
|
||||
<br /><br />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
<a id="btn-accept-leave-session" layout-action="close" class="button-orange">OK</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a id="btn-cancel-leave-session" layout-action="close" class="button-orange">CANCEL</a>
|
||||
<a id="btn-cancel-leave-session" layout-action="close" class="button-grey">CANCEL</a>
|
||||
</div>
|
||||
<br clear="all" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
<!-- Actual Session Screen -->
|
||||
<div layout="screen" layout-id="session" layout-arg="id" class="screen secondary">
|
||||
<div layout="screen" layout-id="session" layout-arg="id" class="screen secondary" id="session-screen">
|
||||
<div class="content-head">
|
||||
<div class="content-icon">
|
||||
<%= image_tag "shared/icon_session.png", {:height => 19, :width => 19} %>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
<a id="btn-accept-terms" layout-action="close" class="button-orange">ACCEPT</a>
|
||||
</div>
|
||||
<div class="right">
|
||||
<a id="btn-cancel-terms" layout-action="close" class="button-orange">CANCEL</a>
|
||||
<a id="btn-cancel-terms" layout-action="close" class="button-grey">CANCEL</a>
|
||||
</div>
|
||||
<br clear="all" />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -69,7 +69,6 @@
|
|||
</div>
|
||||
|
||||
<%= render "clients/invitationDialog" %>
|
||||
<%= render "clients/shareDialog" %>
|
||||
<%= render "users/signupDialog" %>
|
||||
<%= render "users/signinDialog" %>
|
||||
<%= render "users/videoDialog" %>
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@
|
|||
<div class="w100">
|
||||
<div class="recording-controls">
|
||||
<% if !@music_session.music_session.nil? && !@music_session.music_session.mount.blank? %>
|
||||
<a class="left mr20" href="#">
|
||||
<a id="btnPlayPause" class="left mr20">
|
||||
<%= image_tag "content/icon_playbutton.png", {:id => "imgPlayPause", :width => 20, :height => 20, :alt => ""} %>
|
||||
</a>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
<div class="w100">
|
||||
<div class="recording-controls">
|
||||
<% if @claimed_recording.has_mix? %>
|
||||
<a id="btnPlayPause" class="left" href="#">
|
||||
<a id="btnPlayPause" class="left">
|
||||
<%= image_tag "content/icon_playbutton.png", {:id => "imgPlayPause", :width => 20, :height => 20, :alt => ""} %>
|
||||
</a>
|
||||
<% end %>
|
||||
|
|
|
|||
|
|
@ -204,6 +204,8 @@ if defined?(Bundler)
|
|||
config.twitter_app_id = ENV['TWITTER_APP_ID'] || 'nQj2oEeoJZxECC33tiTuIg'
|
||||
config.twitter_app_secret = ENV['TWITTER_APP_SECRET'] || 'Azcy3QqfzYzn2fsojFPYXcn72yfwa0vG6wWDrZ3KT8'
|
||||
|
||||
config.autocheck_create_session_agreement = false;
|
||||
config.autocheck_create_session_agreement = false
|
||||
|
||||
config.max_audio_downloads = 100
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ SampleApp::Application.routes.draw do
|
|||
# user likes
|
||||
match '/users/:id/likings' => 'api_users#liking_index', :via => :get, :as => 'api_user_liking_index'
|
||||
match '/users/:id/likings' => 'api_users#liking_create', :via => :post
|
||||
match '/users/:id/likings' => 'api_users#liking_destroy', :via => :delete
|
||||
match '/users/:id/likings/:likable_id' => 'api_users#liking_destroy', :via => :delete
|
||||
|
||||
# user followers
|
||||
match '/users/:id/followers' => 'api_users#follower_index', :via => :get, :as => 'api_user_follower_index'
|
||||
|
|
@ -169,7 +169,7 @@ SampleApp::Application.routes.draw do
|
|||
# user followings
|
||||
match '/users/:id/followings' => 'api_users#following_index', :via => :get, :as => 'api_user_following_index'
|
||||
match '/users/:id/followings' => 'api_users#following_create', :via => :post
|
||||
match '/users/:id/followings' => 'api_users#following_destroy', :via => :delete
|
||||
match '/users/:id/followings/:followable_id' => 'api_users#following_destroy', :via => :delete
|
||||
|
||||
# favorites
|
||||
match '/users/:id/favorites' => 'api_users#favorite_index', :via => :get, :as => 'api_favorite_index'
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ require 'spec_helper'
|
|||
describe ApiCorporateController do
|
||||
render_views
|
||||
|
||||
|
||||
before(:each) do
|
||||
CorpMailer.deliveries.clear
|
||||
end
|
||||
|
|
@ -0,0 +1,53 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe ApiMixesController do
|
||||
render_views
|
||||
|
||||
let(:mix) { FactoryGirl.create(:mix) }
|
||||
|
||||
before(:each) do
|
||||
controller.current_user = nil
|
||||
end
|
||||
|
||||
describe "download" do
|
||||
|
||||
it "is possible" do
|
||||
controller.current_user = mix.recording.owner
|
||||
get :download, {id: mix.id}
|
||||
response.status.should == 302
|
||||
|
||||
mix.reload
|
||||
mix.download_count.should == 1
|
||||
|
||||
get :download, {id: mix.id}
|
||||
response.status.should == 302
|
||||
|
||||
mix.reload
|
||||
mix.download_count.should == 2
|
||||
end
|
||||
|
||||
|
||||
it "prevents download after limit is reached" do
|
||||
mix.download_count = APP_CONFIG.max_audio_downloads
|
||||
mix.save!
|
||||
controller.current_user = mix.recording.owner
|
||||
get :download, {format:'json', id: mix.id}
|
||||
response.status.should == 404
|
||||
JSON.parse(response.body, symbolize_names: true)[:message].should == "download limit surpassed"
|
||||
end
|
||||
|
||||
|
||||
it "lets admins surpass limit" do
|
||||
mix.download_count = APP_CONFIG.max_audio_downloads
|
||||
mix.save!
|
||||
mix.recording.owner.admin = true
|
||||
mix.recording.owner.save!
|
||||
|
||||
controller.current_user = mix.recording.owner
|
||||
get :download, {format:'json', id: mix.id}
|
||||
response.status.should == 302
|
||||
mix.reload
|
||||
mix.download_count.should == 101
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -101,6 +101,8 @@ describe ApiRecordingsController do
|
|||
end
|
||||
|
||||
describe "download" do
|
||||
let(:mix) { FactoryGirl.create(:mix) }
|
||||
|
||||
it "should only allow a user to download a track if they have claimed the recording" do
|
||||
post :start, { :format => 'json', :music_session_id => @music_session.id }
|
||||
response_body = JSON.parse(response.body)
|
||||
|
|
@ -108,5 +110,51 @@ describe ApiRecordingsController do
|
|||
post :stop, { :format => 'json', :id => recording.id }
|
||||
response.should be_success
|
||||
end
|
||||
|
||||
|
||||
it "is possible" do
|
||||
mix.touch
|
||||
recorded_track = mix.recording.recorded_tracks[0]
|
||||
controller.current_user = mix.recording.owner
|
||||
get :download, {id: recorded_track.recording.id, track_id: recorded_track.client_track_id}
|
||||
response.status.should == 302
|
||||
|
||||
recorded_track.reload
|
||||
recorded_track.download_count.should == 1
|
||||
|
||||
get :download, {id: recorded_track.recording.id, track_id: recorded_track.client_track_id}
|
||||
response.status.should == 302
|
||||
|
||||
recorded_track.reload
|
||||
recorded_track.download_count.should == 2
|
||||
end
|
||||
|
||||
|
||||
it "prevents download after limit is reached" do
|
||||
mix.touch
|
||||
recorded_track = mix.recording.recorded_tracks[0]
|
||||
recorded_track.download_count = APP_CONFIG.max_audio_downloads
|
||||
recorded_track.save!
|
||||
controller.current_user = recorded_track.user
|
||||
get :download, {format:'json', id: recorded_track.recording.id, track_id: recorded_track.client_track_id}
|
||||
response.status.should == 404
|
||||
JSON.parse(response.body, symbolize_names: true)[:message].should == "download limit surpassed"
|
||||
end
|
||||
|
||||
|
||||
it "lets admins surpass limit" do
|
||||
mix.touch
|
||||
recorded_track = mix.recording.recorded_tracks[0]
|
||||
recorded_track.download_count = APP_CONFIG.max_audio_downloads
|
||||
recorded_track.save!
|
||||
recorded_track.user.admin = true
|
||||
recorded_track.user.save!
|
||||
|
||||
controller.current_user = recorded_track.user
|
||||
get :download, {format:'json', id: recorded_track.recording.id, track_id: recorded_track.client_track_id}
|
||||
response.status.should == 302
|
||||
recorded_track.reload
|
||||
recorded_track.download_count.should == 101
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -374,4 +374,23 @@ FactoryGirl.define do
|
|||
factory :music_session_like, :class => JamRuby::MusicSessionLiker do
|
||||
|
||||
end
|
||||
|
||||
|
||||
factory :mix, :class => JamRuby::Mix do
|
||||
started_at Time.now
|
||||
completed_at Time.now
|
||||
ogg_md5 'abc'
|
||||
ogg_length 1
|
||||
sequence(:ogg_url) { |n| "recordings/ogg/#{n}" }
|
||||
mp3_md5 'abc'
|
||||
mp3_length 1
|
||||
sequence(:mp3_url) { |n| "recordings/mp3/#{n}" }
|
||||
completed true
|
||||
|
||||
before(:create) {|mix|
|
||||
user = FactoryGirl.create(:user)
|
||||
mix.recording = FactoryGirl.create(:recording_with_track, owner: user)
|
||||
mix.recording.claimed_recordings << FactoryGirl.create(:claimed_recording, user: user, recording: mix.recording)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ describe "Account", :js => true, :type => :feature, :capybara_feature => true do
|
|||
end
|
||||
|
||||
it {
|
||||
should have_selector('h2', text: 'identity:' )
|
||||
find('#account-identity h2', text: 'identity:')
|
||||
should have_selector('form#account-edit-email-form h4', text: 'Update your email address:')
|
||||
should have_selector('form#account-edit-password-form h4', text: 'Update your password:')
|
||||
}
|
||||
|
|
@ -46,7 +46,7 @@ describe "Account", :js => true, :type => :feature, :capybara_feature => true do
|
|||
end
|
||||
|
||||
it {
|
||||
should have_selector('h1', text: 'my account');
|
||||
find('h1', text: 'my account')
|
||||
should have_selector('#notification h2', text: 'Confirmation Email Sent')
|
||||
}
|
||||
end
|
||||
|
|
@ -68,58 +68,60 @@ describe "Account", :js => true, :type => :feature, :capybara_feature => true do
|
|||
describe "unsuccessfully" do
|
||||
|
||||
before(:each) do
|
||||
find('#account-identity h2', text: 'identity:')
|
||||
find("#account-edit-password-submit").trigger(:click)
|
||||
end
|
||||
|
||||
it {
|
||||
should have_selector('h2', text: 'identity:')
|
||||
should have_selector('div.field.error input[name=current_password] ~ ul li', text: "can't be blank")
|
||||
should have_selector('div.field.error input[name=password] ~ ul li', text: "is too short (minimum is 6 characters)")
|
||||
should have_selector('div.field.error input[name=password_confirmation] ~ ul li', text: "can't be blank")
|
||||
find('#account-identity h2', text: 'identity:')
|
||||
find('#account-identity div.field.error input[name=current_password] ~ ul li', text: "can't be blank")
|
||||
find('#account-identity div.field.error input[name=password] ~ ul li', text: "is too short (minimum is 6 characters)")
|
||||
find('#account-identity div.field.error input[name=password_confirmation] ~ ul li', text: "can't be blank")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
describe "profile"
|
||||
|
||||
before(:each) do
|
||||
find("#account-edit-profile-link").trigger(:click)
|
||||
find('a.small', text: 'Change Avatar')
|
||||
end
|
||||
|
||||
describe "successfully" do
|
||||
describe "profile" do
|
||||
|
||||
before(:each) do
|
||||
fill_in "first_name", with: "Bobby"
|
||||
fill_in "last_name", with: "Toes"
|
||||
find('input[name=subscribe_email]').set(false)
|
||||
find("#account-edit-profile-submit").trigger(:click)
|
||||
find("#account-edit-profile-link").trigger(:click)
|
||||
find('a.small', text: 'Change Avatar')
|
||||
end
|
||||
|
||||
it {
|
||||
user.subscribe_email.should be_true
|
||||
should have_selector('h1', text: 'my account')
|
||||
should have_selector('#notification h2', text: 'Profile Changed')
|
||||
user.reload
|
||||
user.subscribe_email.should be_false
|
||||
user.first_name.should == "Bobby"
|
||||
user.last_name.should == "Toes"
|
||||
}
|
||||
end
|
||||
describe "successfully" do
|
||||
|
||||
describe "unsuccessfully" do
|
||||
before(:each) do
|
||||
fill_in "first_name", with: "Bobby"
|
||||
fill_in "last_name", with: "Toes"
|
||||
find('input[name=subscribe_email]').set(false)
|
||||
find("#account-edit-profile-submit").trigger(:click)
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
fill_in "first_name", with: ""
|
||||
fill_in "last_name", with: ""
|
||||
find("#account-edit-profile-submit").trigger(:click)
|
||||
it {
|
||||
user.subscribe_email.should be_true
|
||||
should have_selector('h1', text: 'my account')
|
||||
should have_selector('#notification h2', text: 'Profile Changed')
|
||||
user.reload
|
||||
user.subscribe_email.should be_false
|
||||
user.first_name.should == "Bobby"
|
||||
user.last_name.should == "Toes"
|
||||
}
|
||||
end
|
||||
|
||||
it {
|
||||
should have_selector('h2', text: 'profile:')
|
||||
should have_selector('div.field.error input[name=first_name] ~ ul li', text: "can't be blank")
|
||||
should have_selector('div.field.error input[name=last_name] ~ ul li', text: "can't be blank")
|
||||
}
|
||||
describe "unsuccessfully" do
|
||||
|
||||
before(:each) do
|
||||
fill_in "first_name", with: ""
|
||||
fill_in "last_name", with: ""
|
||||
find("#account-edit-profile-submit").trigger(:click)
|
||||
end
|
||||
|
||||
it {
|
||||
should have_selector('h2', text: 'profile:')
|
||||
should have_selector('div.field.error input[name=first_name] ~ ul li', text: "can't be blank")
|
||||
should have_selector('div.field.error input[name=last_name] ~ ul li', text: "can't be blank")
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -36,6 +36,12 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature
|
|||
# confirms that a formal leave (by hitting the 'Leave' button) will result in a good recording
|
||||
it "creator starts and then leaves" do
|
||||
start_recording_with(creator, [joiner1])
|
||||
in_client(creator) do
|
||||
find('#session-leave').trigger(:click)
|
||||
find('#btn-accept-leave-session').trigger(:click)
|
||||
expect(page).to have_selector('h2', text: 'feed')
|
||||
end
|
||||
|
||||
formal_leave_by creator
|
||||
check_recording_finished_for [creator, joiner1]
|
||||
end
|
||||
|
|
@ -67,6 +73,7 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature
|
|||
|
||||
it "creator starts with session leave to stop, with 3 total participants" do
|
||||
start_recording_with(creator, [joiner1, joiner2])
|
||||
|
||||
formal_leave_by creator
|
||||
check_recording_finished_for [creator, joiner1, joiner2]
|
||||
end
|
||||
|
|
|
|||
|
|
@ -524,6 +524,7 @@ describe "Music Session API ", :type => :api do
|
|||
# this test was created to stop duplication of tracks
|
||||
# but ultimately it should be fine to create a session, and then 'join' it with no ill effects
|
||||
# https://jamkazam.atlassian.net/browse/VRFS-254
|
||||
user.admin = true
|
||||
client = FactoryGirl.create(:connection, :user => user)
|
||||
post '/api/sessions.json', defopts.merge({:client_id => client.client_id}).to_json, "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should eql(201)
|
||||
|
|
@ -543,7 +544,6 @@ describe "Music Session API ", :type => :api do
|
|||
track["instrument_id"].should == "electric guitar"
|
||||
track["sound"].should == "mono"
|
||||
|
||||
|
||||
post "/api/sessions/#{music_session["id"]}/participants.json", { :client_id => client.client_id, :as_musician => true, :tracks => [{"instrument_id" => "electric guitar", "sound" => "mono", "client_track_id" => "client_track_guid"}]}.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
|
||||
last_response.status.should eql(201)
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ describe "User API", :type => :api do
|
|||
|
||||
def delete_user_like(authenticated_user, source_user, target_user)
|
||||
login(authenticated_user.email, authenticated_user.password, 200, true)
|
||||
delete "/api/users/#{source_user.id}/likings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
delete "/api/users/#{source_user.id}/likings/#{target_user.id}.json", "CONTENT_TYPE" => 'application/json'
|
||||
return last_response
|
||||
end
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ describe "User API", :type => :api do
|
|||
|
||||
def delete_user_following(authenticated_user, source_user, target_user)
|
||||
login(authenticated_user.email, authenticated_user.password, 200, true)
|
||||
delete "/api/users/#{source_user.id}/followings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
|
||||
delete "/api/users/#{source_user.id}/followings/#{target_user.id}.json", "CONTENT_TYPE" => 'application/json'
|
||||
return last_response
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
require 'simplecov'
|
||||
require 'rubygems'
|
||||
require 'spork'
|
||||
#require 'spork'
|
||||
require 'omniauth'
|
||||
#uncomment the following line to use spork with the debugger
|
||||
#require 'spork/ext/ruby-debug'
|
||||
|
|
@ -40,7 +40,7 @@ Thread.new {
|
|||
end
|
||||
}
|
||||
|
||||
Spork.prefork do
|
||||
#Spork.prefork do
|
||||
# Loading more in this block will cause your tests to run faster. However,
|
||||
# if you change any configuration or code from libraries loaded here, you'll
|
||||
# need to restart spork for it take effect.
|
||||
|
|
@ -155,12 +155,12 @@ Spork.prefork do
|
|||
wipe_s3_test_bucket
|
||||
end
|
||||
end
|
||||
end
|
||||
#end
|
||||
|
||||
Spork.each_run do
|
||||
#Spork.each_run do
|
||||
# This code will be run each time you run your specs.
|
||||
|
||||
end
|
||||
#end
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -174,6 +174,7 @@ def create_session(creator = FactoryGirl.create(:user), unique_session_desc = ni
|
|||
|
||||
# verify that the in-session page is showing
|
||||
expect(page).to have_selector('h2', text: 'my tracks')
|
||||
find('#session-screen .session-mytracks .session-track')
|
||||
end
|
||||
|
||||
return creator, unique_session_desc, genre
|
||||
|
|
@ -195,6 +196,7 @@ def join_session(joiner, unique_session_desc)
|
|||
find('.join-link').trigger(:click)
|
||||
find('#btn-accept-terms').trigger(:click)
|
||||
expect(page).to have_selector('h2', text: 'my tracks')
|
||||
find('#session-screen .session-mytracks .session-track')
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -211,7 +213,7 @@ end
|
|||
def formal_leave_by user
|
||||
in_client(user) do
|
||||
find('#session-leave').trigger(:click)
|
||||
find('#btn-accept-leave-session').trigger(:click)
|
||||
#find('#btn-accept-leave-session').trigger(:click)
|
||||
expect(page).to have_selector('h2', text: 'feed')
|
||||
end
|
||||
end
|
||||
|
|
@ -336,7 +338,7 @@ def assert_all_tracks_seen(users=[])
|
|||
users.each do |user|
|
||||
in_client(user) do
|
||||
users.reject {|u| u==user}.each do |other|
|
||||
expect(page).to have_selector('div.track-label', text: other.name)
|
||||
find('div.track-label', text: other.name)
|
||||
#puts user.name + " is able to see " + other.name + "\'s track"
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue