* VRFS-2606 - add new tap in fields, support them in activeadmin
This commit is contained in:
parent
b4fed74b50
commit
2ff30946e8
|
|
@ -27,6 +27,8 @@ ActiveAdmin.register JamRuby::JamTrack, :as => 'JamTracks' do
|
|||
column :name
|
||||
column :description
|
||||
column :bpm
|
||||
column :tap_in_count
|
||||
column :initial_play_silence
|
||||
column :time_signature
|
||||
column :status
|
||||
column :recording_type
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
= f.input :name, :input_html => { :rows=>1, :maxlength=>200 }
|
||||
= f.input :description, :input_html => { :rows=>5, :maxlength=>1000 }
|
||||
= f.input :bpm
|
||||
= f.input :tap_in_count
|
||||
= f.input :initial_play_silence, :label => 'Initial Play Silence (seconds)'
|
||||
= f.input :time_signature, collection: JamRuby::JamTrack::TIME_SIGNATURES, include_blank: false
|
||||
= f.input :status, collection: JamRuby::JamTrack::STATUS, include_blank: false
|
||||
= f.input :recording_type, collection: JamRuby::JamTrack::RECORDING_TYPE, include_blank: false
|
||||
|
|
@ -26,7 +28,10 @@
|
|||
|
||||
= f.semantic_fields_for :jam_track_tracks do |track|
|
||||
= render 'jam_track_track_fields', f: track
|
||||
= f.semantic_fields_for :jam_track_tap_ins do |tap_in|
|
||||
= render 'jam_track_tap_in_fields', f: tap_in
|
||||
.links
|
||||
= link_to_add_association 'Add Track', f, :jam_track_tracks, class: 'button', style: 'margin:20px;padding:10px 20px'
|
||||
= link_to_add_association 'Add Tap In', f, :jam_track_tap_ins, class: 'button', style: 'margin:20px;padding:10px 20px'
|
||||
|
||||
= f.actions
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
= f.inputs name: 'Tap In fields' do
|
||||
|
||||
ol.nested-fields
|
||||
= f.input :offset_time, :required=>true
|
||||
|
||||
- if f.object.new_record?
|
||||
p style='margin-left:10px'
|
||||
i
|
||||
| before you can create a tap in, you must have created the JamTrack.
|
||||
= link_to_remove_association "Delete Tap In", f, class: 'button', style: 'margin-left:10px'
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
= f.inputs name: 'Track fields' do
|
||||
|
||||
%ol.nested-fields
|
||||
ol.nested-fields
|
||||
= f.input :track_type, :as => :select, collection: JamRuby::JamTrackTrack::TRACK_TYPE, include_blank: false
|
||||
= f.input :instrument, collection: Instrument.all, include_blank: false
|
||||
= f.input :part, :required=>true, :input_html => { :rows=>1, :maxlength=>20, :type=>'numeric' }
|
||||
|
|
@ -8,12 +8,14 @@
|
|||
= f.input :position
|
||||
|
||||
- if f.object.new_record?
|
||||
%p{style: 'margin-left:10px'}
|
||||
%i before you can upload, you must select 'Update JamTrack'
|
||||
p style='margin-left:10px'
|
||||
i
|
||||
| before you can upload, you must select 'Update JamTrack'
|
||||
- else
|
||||
= f.input :url, :as => :file, :label => 'Track file'
|
||||
- unless f.object.nil? || f.object[:url].nil?
|
||||
.current_file_holder{style: 'margin-bottom:10px'}
|
||||
%a{href: f.object.sign_url(3600), style: 'padding:0 0 0 20px'} Download
|
||||
.current_file_holder style='margin-bottom:10px'
|
||||
a href=f.object.sign_url(3600) style='padding:0 0 0 20px'
|
||||
| Download
|
||||
|
||||
= link_to_remove_association "Delete Track", f, class: 'button', style: 'margin-left:10px'
|
||||
|
|
@ -236,3 +236,4 @@ icecast_source_changes.sql
|
|||
diagnostics_user_id_index.sql
|
||||
jam_track_updates.sql
|
||||
private_key_in_jam_track_rights.sql
|
||||
jam_track_tap_in.sql
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
-- offset is milliseconds
|
||||
CREATE TABLE jam_track_tap_ins (
|
||||
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
offset_time INTEGER NOT NULL,
|
||||
jam_track_id BIGINT NOT NULL REFERENCES jam_tracks(id) ON DELETE CASCADE
|
||||
);
|
||||
|
||||
ALTER TABLE jam_tracks ADD COLUMN tap_in_count INTEGER NOT NULL DEFAULT 0;
|
||||
ALTER TABLE jam_tracks ADD COLUMN initial_play_silence DECIMAL NOT NULL DEFAULT 5;
|
||||
|
|
@ -184,6 +184,7 @@ require "jam_ruby/models/jam_track_licensor"
|
|||
require "jam_ruby/models/jam_track"
|
||||
require "jam_ruby/models/jam_track_track"
|
||||
require "jam_ruby/models/jam_track_right"
|
||||
require "jam_ruby/models/jam_track_tap_in"
|
||||
require "jam_ruby/app/mailers/async_mailer"
|
||||
require "jam_ruby/app/mailers/batch_mailer"
|
||||
require "jam_ruby/app/mailers/progress_mailer"
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ module JamRuby
|
|||
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, :jam_track_tracks_attributes, :plan_code, as: :admin
|
||||
:licensor_royalty_amount, :pro_royalty_amount, :plan_code, :tap_in_count, :initial_play_silence, :jam_track_tracks_attributes, :jam_track_tap_ins_attributes, as: :admin
|
||||
|
||||
validates :name, presence: true, uniqueness: true, length: {maximum: 200}
|
||||
validates :description, length: {maximum: 1000}
|
||||
|
|
@ -29,6 +29,8 @@ module JamRuby
|
|||
validates :pro, inclusion: {in: [nil] + PRO}
|
||||
validates :sales_region, inclusion: {in: [nil] + SALES_REGION}
|
||||
validates_format_of :price, with: /^\d+\.*\d{0,2}$/
|
||||
validates :tap_in_count, presence: true, numericality: {only_integer: true}
|
||||
validates :initial_play_silence, numericality: true, :allow_nil => true
|
||||
|
||||
validates :reproduction_royalty, inclusion: {in: [nil, true, false]}
|
||||
validates :public_performance_royalty, inclusion: {in: [nil, true, false]}
|
||||
|
|
@ -42,11 +44,13 @@ module JamRuby
|
|||
belongs_to :licensor , class_name: 'JamRuby::JamTrackLicensor', foreign_key: 'licensor_id'
|
||||
|
||||
has_many :jam_track_tracks, :class_name => "JamRuby::JamTrackTrack", order: 'position ASC'
|
||||
has_many :jam_track_tap_ins, :class_name => "JamRuby::JamTrackTapIn", order: 'offset_time ASC'
|
||||
|
||||
has_many :jam_track_rights, :class_name => "JamRuby::JamTrackRight" #, inverse_of: 'jam_track', :foreign_key => "jam_track_id"
|
||||
has_many :owners, :through => :jam_track_rights, :class_name => "JamRuby::User", :source => :user
|
||||
|
||||
accepts_nested_attributes_for :jam_track_tracks, allow_destroy: true
|
||||
accepts_nested_attributes_for :jam_track_tap_ins, allow_destroy: true
|
||||
|
||||
class << self
|
||||
def index(options = {})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,11 @@
|
|||
module JamRuby
|
||||
class JamTrackTapIn < ActiveRecord::Base
|
||||
|
||||
attr_accessible :jam_track_id, :offset_time, as: :admin
|
||||
|
||||
validates :offset_time, presence: true, numericality: {only_integer: true}, length: {in: 1..1000}
|
||||
validates :jam_track, presence: true
|
||||
|
||||
belongs_to :jam_track, class_name: "JamRuby::JamTrack"
|
||||
end
|
||||
end
|
||||
|
|
@ -732,4 +732,9 @@ FactoryGirl.define do
|
|||
association :jam_track, factory: :jam_track
|
||||
association :user, factory: :user
|
||||
end
|
||||
|
||||
factory :jam_track_tap_in, :class => JamRuby::JamTrackTapIn do
|
||||
association :jam_track, factory: :jam_track
|
||||
offset_time 0
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe JamTrackTapIn do
|
||||
|
||||
it "creates successfully" do
|
||||
FactoryGirl.create(:jam_track_tap_in)
|
||||
end
|
||||
|
||||
it "offset must be specified" do
|
||||
FactoryGirl.build(:jam_track_tap_in, offset_time: nil).valid?.should be_false
|
||||
end
|
||||
|
||||
it "jam_track must be specified" do
|
||||
FactoryGirl.build(:jam_track_tap_in, jam_track: nil).valid?.should be_false
|
||||
end
|
||||
end
|
||||
|
|
@ -709,6 +709,7 @@ FactoryGirl.define do
|
|||
licensor_royalty_amount 0.999
|
||||
pro_royalty_amount 0.999
|
||||
plan_code 'jamtrack-acdc-backinblack'
|
||||
tap_in_count 0
|
||||
ignore do
|
||||
make_track true
|
||||
end
|
||||
|
|
@ -734,4 +735,9 @@ FactoryGirl.define do
|
|||
association :jam_track, factory: :jam_track
|
||||
association :user, factory: :user
|
||||
end
|
||||
|
||||
factory :jam_track_tap_in, :class => JamRuby::JamTrackTapIn do
|
||||
association :jam_track, factory: :jam_track
|
||||
offset_time 0
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue