VRFS-2696 edit musician profile API enhancements

This commit is contained in:
Brian Smith 2015-02-15 08:23:26 -05:00
parent 4b97807fc8
commit 09b4ed09a4
3 changed files with 28 additions and 6 deletions

View File

@ -21,12 +21,18 @@ module JamRuby
OnlinePresence.where("user_id = ?", options[:id])
end
def self.create(current_user, options = {})
def self.create(current_user, options = {}, save = true)
auth_user(current_user, options)
raise StateError, "Missing required information" if options[:service_type].blank? || options[:username].blank?
up = OnlinePresence.new({:user_id => current_user.id, :service_type => options[:service_type], :username => options[:username]})
up.save!
up = OnlinePresence.new({
:user_id => current_user.id,
:service_type => options[:service_type],
:username => options[:username]
})
up.save! if save
up
end
def self.update(current_user, options = {})

View File

@ -41,7 +41,7 @@ module JamRuby
PerformanceSample.where("user_id = ?", options[:id])
end
def self.create(current_user, options = {})
def self.create(current_user, options = {}, save = true)
auth_user(current_user, options)
raise StateError, "Missing required information" if options[:service_type].blank?
@ -53,7 +53,8 @@ module JamRuby
:url => options[:url]
})
ps.save!
ps.save! if save
ps
end
def self.delete(current_user, options = {})

View File

@ -638,7 +638,6 @@ module JamRuby
end
gids.each do |gid|
genre_player = GenrePlayer.new
genre_player.player_id = self.id
genre_player.player_type = self.class.name
@ -649,9 +648,25 @@ module JamRuby
end
def update_online_presences(online_presences)
unless self.new_record?
OnlinePresence.delete_all(["user_id = ?", self.id])
end
online_presences.each do |op|
op = OnlinePresence.create(self.id, online_presences, false)
self.online_presences << op
end
end
def update_performance_samples(performance_samples)
unless self.new_record?
PerformanceSample.delete_all(["user_id = ?", self.id])
end
performance_samples.each do |ps|
ps = PerformanceSample.create(self.id, performance_samples, false)
self.performance_samples << ps
end
end
# given an array of instruments, update a user's instruments