VRFS-305 musician profile bands tab
This commit is contained in:
parent
00578afc49
commit
72cdd1b4d7
|
|
@ -39,6 +39,7 @@ require "jam_ruby/models/artifact_update"
|
|||
require "jam_ruby/models/band_invitation"
|
||||
require "jam_ruby/models/band_liker"
|
||||
require "jam_ruby/models/band_follower"
|
||||
require "jam_ruby/models/band_following"
|
||||
require "jam_ruby/models/band_musician"
|
||||
require "jam_ruby/models/connection"
|
||||
require "jam_ruby/models/friendship"
|
||||
|
|
|
|||
|
|
@ -20,8 +20,10 @@ module JamRuby
|
|||
has_many :inverse_likers, :through => :likers, :class_name => "JamRuby::User", :foreign_key => "liker_id"
|
||||
|
||||
# followers
|
||||
has_many :followers, :class_name => "JamRuby::BandFollower", :foreign_key => "band_id", :inverse_of => :band
|
||||
has_many :inverse_followers, :through => :followers, :class_name => "JamRuby::User", :foreign_key => "follower_id"
|
||||
has_many :band_followers, :class_name => "JamRuby::BandFollower", :foreign_key => "band_id"
|
||||
has_many :followers, :through => :band_followers, :class_name => "JamRuby::Band"
|
||||
has_many :inverse_band_followers, :through => :followers, :class_name => "JamRuby::BandFollower", :foreign_key => "follower_id"
|
||||
has_many :inverse_followers, :through => :inverse_band_followers, :source => :band, :class_name => "JamRuby::Band"
|
||||
|
||||
# invitations
|
||||
has_many :invitations, :inverse_of => :band, :class_name => "JamRuby::BandInvitation", :foreign_key => "band_id"
|
||||
|
|
@ -46,9 +48,10 @@ module JamRuby
|
|||
end
|
||||
|
||||
def location
|
||||
# TODO: implement a single string version of location;
|
||||
# this will be indexed into elasticsearch and returned in search
|
||||
return "#{self.city}, #{self.state}, #{self.country}"
|
||||
loc = self.city.blank? ? '' : self.city
|
||||
loc = loc.blank? ? self.state : "#{loc}, #{self.state}" unless self.state.blank?
|
||||
#loc = loc.blank? ? self.country : "#{loc}, #{self.country}" unless self.country.blank?
|
||||
loc
|
||||
end
|
||||
|
||||
def add_member(user_id, admin)
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ module JamRuby
|
|||
|
||||
self.primary_key = 'id'
|
||||
|
||||
belongs_to :band, :class_name => "JamRuby::Band", :foreign_key => "band_id", :inverse_of => :followers
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "follower_id", :inverse_of => :band_followings
|
||||
belongs_to :band, :class_name => "JamRuby::Band", :foreign_key => "band_id", :inverse_of => :inverse_band_followers
|
||||
belongs_to :follower, :class_name => "JamRuby::User", :foreign_key => "follower_id", :inverse_of => :band_followers
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
module JamRuby
|
||||
class BandFollowing < ActiveRecord::Base
|
||||
|
||||
self.table_name = "bands_followers"
|
||||
|
||||
self.primary_key = 'id'
|
||||
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "follower_id", :inverse_of => :inverse_band_followings
|
||||
belongs_to :band_following, :class_name => "JamRuby::Band", :foreign_key => "band_id", :inverse_of => :band_followings
|
||||
end
|
||||
end
|
||||
|
|
@ -59,8 +59,10 @@ module JamRuby
|
|||
has_many :inverse_followings, :through => :inverse_user_followings, :source => :user, :class_name => "JamRuby::User"
|
||||
|
||||
# band followings
|
||||
has_many :band_followings, :class_name => "JamRuby::BandFollower", :foreign_key => "follower_id", :inverse_of => :user
|
||||
has_many :inverse_band_followings, :through => :band_followings, :class_name => "JamRuby::Band", :foreign_key => "band_id"
|
||||
has_many :b_followings, :class_name => "JamRuby::BandFollowing", :foreign_key => "follower_id"
|
||||
has_many :band_followings, :through => :b_followings, :class_name => "JamRuby::Band"
|
||||
has_many :inverse_b_followings, :through => :band_followings, :class_name => "JamRuby::BandFollowing", :foreign_key => "band_id"
|
||||
has_many :inverse_band_followings, :through => :inverse_band_followings, :source => :band, :class_name => "JamRuby::Band"
|
||||
|
||||
# favorites
|
||||
has_many :favorites, :class_name => "JamRuby::UserFavorite", :foreign_key => "user_id"
|
||||
|
|
|
|||
Loading…
Reference in New Issue