* allow null parts on instrument assignment

This commit is contained in:
Seth Call 2015-12-19 21:21:59 -06:00
parent 15e1e757dd
commit 7a8775cbf6
2 changed files with 20 additions and 20 deletions

View File

@ -1206,9 +1206,9 @@ module JamRuby
instrument_weight = nil
# if there are any persisted tracks, do not sort from scratch; just stick new stuff at the end
if track.persisted?
instrument_weight = track.position
else
#if track.persisted?
# instrument_weight = track.position
#else
if track.instrument_id == 'voice'
if track.part && track.part.start_with?('Lead')
@ -1275,7 +1275,7 @@ module JamRuby
if track.track_type == 'Click'
instrument_weight = 10000
end
end
#end
instrument_weight
@ -1336,19 +1336,10 @@ module JamRuby
end
end
# default to 1, but if there are any persisted tracks, this will get manipulated to be +1 the highest persisted track
position = 1
sorted_tracks.each do |track|
if track.persisted?
# persisted tracks should be sorted at the beginning of the sorted_tracks,
# so this just keeps moving the 'position builder' up to +1 of the last persisted track
position = track.position + 1
else
track.position = position
position = position + 1
end
track.position = position
position = position + 1
end
# get click/master tracks position re-set correctly
@ -1498,12 +1489,21 @@ module JamRuby
deduplicate_parts(tracks)
changed = false
tracks.each do |track|
if track.changed?
changed = true
puts "CHANGE: #{track.changes.inspect}"
track.skip_inst_part_uniq = true
track.save!
end
if !track.save!
finish('invalid_audio', track.errors.inspect)
end
if changed
# if we messed up any instrument/parts by making a dup, this will catch it
tracks.each do |track|
track.skip_inst_part_uniq = false
track.save!
end
end
end
@ -1549,7 +1549,7 @@ module JamRuby
track.instrument_id = parsed_wav[:instrument] || 'other'
track.track_type = 'Track'
track.part = parsed_wav[:part] || "Other #{unknowns}"
track.part = parsed_wav[:part];
tracks << track
elsif parsed_wav[:type] == :clicktxt
file.file_type = 'ClickTxt'

View File

@ -19,7 +19,7 @@ module JamRuby
attr_accessible :jam_track_id, :track_type, :instrument, :instrument_id, :position, :part, as: :admin
attr_accessible :url_44, :url_48, :md5_44, :md5_48, :length_44, :length_48, :preview_start_time_raw, as: :admin
attr_accessor :original_audio_s3_path, :skip_uploader, :preview_generate_error, :wav_file, :tmp_duration
attr_accessor :original_audio_s3_path, :skip_uploader, :preview_generate_error, :wav_file, :tmp_duration, :skip_inst_part_uniq
before_destroy :delete_s3_files
@ -27,7 +27,7 @@ module JamRuby
validates :part, length: {maximum: 35}
validates :track_type, inclusion: {in: TRACK_TYPE }
validates :preview_start_time, numericality: {only_integer: true}, length: {in: 1..1000}, :allow_nil => true
validates_uniqueness_of :part, scope: [:jam_track_id, :instrument_id]
validates_uniqueness_of :part, scope: [:jam_track_id, :instrument_id], unless: :skip_inst_part_uniq
# validates :jam_track, presence: true
belongs_to :instrument, class_name: "JamRuby::Instrument"