2012-10-28 02:35:28 +00:00
|
|
|
module JamRuby
|
|
|
|
|
class Instrument < ActiveRecord::Base
|
|
|
|
|
|
2013-11-26 14:40:06 +00:00
|
|
|
MAP_ICON_NAME = {
|
|
|
|
|
"accordion" => "accordion",
|
2014-04-03 04:19:39 +00:00
|
|
|
"acoustic guitar" => "acoustic_guitar",
|
2013-11-26 14:40:06 +00:00
|
|
|
"banjo" => "banjo",
|
2014-04-03 04:19:39 +00:00
|
|
|
"bass guitar" => "bass_guitar",
|
2013-11-26 14:40:06 +00:00
|
|
|
"cello" => "cello",
|
|
|
|
|
"clarinet" => "clarinet",
|
|
|
|
|
"computer" => "computer",
|
|
|
|
|
"default" => "default",
|
|
|
|
|
"drums" => "drums",
|
2014-04-03 04:19:39 +00:00
|
|
|
"electric guitar" => "electric_guitar",
|
2013-11-26 14:40:06 +00:00
|
|
|
"euphonium" => "euphonium",
|
|
|
|
|
"flute" => "flute",
|
2014-04-03 04:19:39 +00:00
|
|
|
"french horn" => "french_horn",
|
2013-11-26 14:40:06 +00:00
|
|
|
"harmonica" => "harmonica",
|
|
|
|
|
"keyboard" => "keyboard",
|
|
|
|
|
"mandolin" => "mandolin",
|
|
|
|
|
"oboe" => "oboe",
|
|
|
|
|
"other" => "other",
|
2014-04-03 04:19:39 +00:00
|
|
|
"piano" => "piano",
|
2013-11-26 14:40:06 +00:00
|
|
|
"saxophone" => "saxophone",
|
|
|
|
|
"trombone" => "trombone",
|
|
|
|
|
"trumpet" => "trumpet",
|
|
|
|
|
"tuba" => "tuba",
|
|
|
|
|
"ukulele" => "ukelele",
|
2014-04-03 04:19:39 +00:00
|
|
|
"upright bass" => "upright_bass",
|
2013-11-26 14:40:06 +00:00
|
|
|
"viola" => "viola",
|
|
|
|
|
"violin" => "violin",
|
2014-04-03 04:19:39 +00:00
|
|
|
"voice" => "voice"
|
2013-11-26 14:40:06 +00:00
|
|
|
}
|
|
|
|
|
|
2012-10-28 02:35:28 +00:00
|
|
|
self.primary_key = 'id'
|
|
|
|
|
|
2012-10-29 10:45:47 +00:00
|
|
|
# users
|
2012-11-21 19:48:39 +00:00
|
|
|
has_many :musician_instruments, :class_name => "JamRuby::MusicianInstrument"
|
VRFS-3242 : Schema and model changes required for band profile functionality.
* Additional attributes for band_type, band_status, concert_count,
add_new_members, play_commitment, touring_option, paid_gigs,
hourly_rate, gig_minimum
* For joined table musician_instruments, remove the hard requirement
that they be joined to a user, rather a “player” that is polymorphic.
* For joined table performance_stamples, remove the hard requirement
that they be joined to a user, rather a “player” that is polymorphic.
* For joined table online_presences, remove the hard requirement that
they be joined to a user, rather a “player” that is polymorphic.
* Change models as appropriate with new attributes and modify
belongs_to / has_many directives as necessary.
* Fix existing usages of user_id to work with polymorphic player_id.
* Fix tests that use user_id
* Add new tests that exercise online_presence, performance_samples, and
instruments that target a band, rather than a user.
2015-05-14 02:06:14 +00:00
|
|
|
has_many :players, :through => :musician_instruments
|
2012-12-15 07:11:04 +00:00
|
|
|
has_many :tracks, :class_name => "JamRuby::Track", :inverse_of => :instrument
|
2013-01-22 19:15:52 +00:00
|
|
|
has_many :recorded_tracks, :class_name => "JamRuby::RecordedTrack", :inverse_of => :instrument
|
2012-10-29 10:45:47 +00:00
|
|
|
|
|
|
|
|
# music sessions
|
2014-05-06 13:34:38 +00:00
|
|
|
has_and_belongs_to_many :music_sessions, :class_name => "JamRuby::ActiveMusicSession", :join_table => "genres_music_sessions"
|
2013-03-15 04:22:31 +00:00
|
|
|
|
2015-07-27 15:02:37 +00:00
|
|
|
# teachers
|
|
|
|
|
has_and_belongs_to_many :teachers, :class_name => "JamRuby::Teacher", :join_table => "teachers_instruments"
|
|
|
|
|
|
2013-03-15 04:22:31 +00:00
|
|
|
def self.standard_list
|
2016-04-27 03:22:49 +00:00
|
|
|
return Instrument.where('instruments.popularity > 0').order('instruments.description ASC')
|
2013-03-15 04:22:31 +00:00
|
|
|
end
|
|
|
|
|
|
2015-08-01 22:24:41 +00:00
|
|
|
def self.jam_track_list
|
|
|
|
|
sql = "SELECT DISTINCT instrument_id FROM jam_track_tracks WHERE instrument_id IS NOT NULL"
|
|
|
|
|
Instrument.where("instruments.id IN (#{sql})")
|
|
|
|
|
.order('instruments.description ASC')
|
|
|
|
|
end
|
|
|
|
|
|
2013-11-26 14:40:06 +00:00
|
|
|
def icon_name
|
|
|
|
|
MAP_ICON_NAME[self.id]
|
|
|
|
|
end
|
|
|
|
|
|
2014-02-11 15:53:20 +00:00
|
|
|
def to_s
|
|
|
|
|
description
|
|
|
|
|
end
|
|
|
|
|
|
2012-10-28 02:35:28 +00:00
|
|
|
end
|
2013-01-15 02:13:45 +00:00
|
|
|
end
|