VRFS-2695 VRFS-2696 wip get/update musician profile API changes
This commit is contained in:
parent
a778eaef28
commit
0a1837c4e6
|
|
@ -14,7 +14,7 @@ module Limits
|
|||
|
||||
# instruments
|
||||
MIN_INSTRUMENTS_PER_MUSICIAN = 1
|
||||
MAX_INSTRUMENTS_PER_MUSICIAN = 5
|
||||
MAX_INSTRUMENTS_PER_MUSICIAN = 1000
|
||||
|
||||
# users
|
||||
USERS_CAN_INVITE = true
|
||||
|
|
|
|||
|
|
@ -1,6 +1,13 @@
|
|||
module JamRuby
|
||||
class GenrePlayer < ActiveRecord::Base
|
||||
|
||||
PROFILE = 'profile'
|
||||
VIRTUAL_BAND = 'virtual_band'
|
||||
TRADITIONAL_BAND = 'traditional_band'
|
||||
PAID_SESSION = 'paid_session'
|
||||
FREE_SESSION = 'free_session'
|
||||
COWRITING = 'cowriting'
|
||||
|
||||
self.table_name = "genre_players"
|
||||
|
||||
belongs_to :player, polymorphic: true
|
||||
|
|
|
|||
|
|
@ -631,16 +631,29 @@ module JamRuby
|
|||
return recordings
|
||||
end
|
||||
|
||||
def update_genres(gids)
|
||||
def update_genres(gids, genre_type)
|
||||
unless self.new_record?
|
||||
GenrePlayer.delete_all(["player_id = ? AND player_type = ?",
|
||||
self.id, self.class.name])
|
||||
GenrePlayer.delete_all(["player_id = ? AND player_type = ? AND genre_type = ?",
|
||||
self.id, self.class.name, genre_type])
|
||||
end
|
||||
|
||||
gids.each do |gid|
|
||||
self.genres << Genre.find_by_id(gid)
|
||||
|
||||
genre_player = GenrePlayer.new
|
||||
genre_player.player_id = self.id
|
||||
genre_player.player_type = self.class.name
|
||||
genre_player.genre_id = gid
|
||||
genre_player.genre_type = genre_type
|
||||
self.genre_players << genre_player
|
||||
end
|
||||
end
|
||||
|
||||
def update_online_presences(online_presences)
|
||||
end
|
||||
|
||||
def update_performance_samples(performance_samples)
|
||||
end
|
||||
|
||||
# given an array of instruments, update a user's instruments
|
||||
def update_instruments(instruments)
|
||||
# delete all instruments for this user first
|
||||
|
|
@ -661,6 +674,8 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def
|
||||
|
||||
# this easy_save routine guards against nil sets, but many of these fields can be set to null.
|
||||
# I've started to use it less as I go forward
|
||||
def easy_save(first_name, last_name, email, password, password_confirmation, musician, gender,
|
||||
|
|
|
|||
|
|
@ -58,10 +58,45 @@ class ApiUsersController < ApiController
|
|||
@user.country = params[:country] if params.has_key?(:country)
|
||||
@user.musician = params[:musician] if params.has_key?(:musician)
|
||||
@user.update_instruments(params[:instruments].nil? ? [] : params[:instruments]) if params.has_key?(:instruments)
|
||||
@user.update_genres(params[:genres].nil? ? [] : params[:genres]) if params.has_key?(:genres)
|
||||
|
||||
# genres
|
||||
@user.update_genres(params[:genres].nil? ? [] : params[:genres], GenrePlayer::PROFILE) if params.has_key?(:genres)
|
||||
@user.update_genres(params[:virtual_band_genres].nil? ? [] : params[:virtual_band_genres], GenrePlayer::VIRTUAL_BAND) if params.has_key?(:virtual_band_genres)
|
||||
@user.update_genres(params[:traditional_band_genres].nil? ? [] : params[:traditional_band_genres], GenrePlayer::TRADITIONAL_BAND) if params.has_key?(:traditional_band_genres)
|
||||
@user.update_genres(params[:paid_session_genres].nil? ? [] : params[:paid_session_genres], GenrePlayer::PAID_SESSION) if params.has_key?(:paid_session_genres)
|
||||
@user.update_genres(params[:free_session_genres].nil? ? [] : params[:free_session_genres], GenrePlayer::FREE_SESSION) if params.has_key?(:free_session_genres)
|
||||
@user.update_genres(params[:cowriting_genres].nil? ? [] : params[:cowriting_genres], GenrePlayer::COWRITING) if params.has_key?(:cowriting_genres)
|
||||
|
||||
@user.show_whats_next = params[:show_whats_next] if params.has_key?(:show_whats_next)
|
||||
@user.subscribe_email = params[:subscribe_email] if params.has_key?(:subscribe_email)
|
||||
@user.biography = params[:biography] if params.has_key?(:biography)
|
||||
|
||||
@user.website = params[:website] if params.has_key?(:website)
|
||||
@user.skill_level = params[:skill_level] if params.has_key?(:skill_level)
|
||||
@user.concert_count = params[:concert_count] if params.has_key?(:concert_count)
|
||||
@user.studio_session_count = params[:studio_session_count] if params.has_key?(:studio_session_count)
|
||||
|
||||
# virtual band
|
||||
@user.virtual_band = params[:virtual_band] if params.has_key?(:virtual_band)
|
||||
@user.virtual_band_commitment = params[:virtual_band_commitment] if params.has_key?(:virtual_band_commitment)
|
||||
|
||||
# traditional band
|
||||
@user.traditional_band = params[:traditional_band] if params.has_key?(:traditional_band)
|
||||
@user.traditional_band_commitment = params[:traditional_band_commitment] if params.has_key?(:traditional_band_commitment)
|
||||
@user.traditional_band_touring = params[:traditional_band_touring] if params.has_key?(:traditional_band_touring)
|
||||
|
||||
# paid sessions
|
||||
@user.paid_sessions = params[:paid_sessions] if params.has_key?(:paid_sessions)
|
||||
@user.paid_sessions_hourly_rate = params[:paid_sessions_hourly_rate] if params.has_key?(:paid_sessions_hourly_rate)
|
||||
@user.paid_sessions_daily_rate = params[:paid_sessions_daily_rate] if params.has_key?(:paid_sessions_daily_rate)
|
||||
|
||||
# free sessions
|
||||
@user.free_sessions = params[:free_sessions] if params.has_key?(:free_sessions)
|
||||
|
||||
# co-writing
|
||||
@user.cowriting = params[:cowriting] if params.has_key?(:cowriting)
|
||||
@user.cowriting_purpose = params[:cowriting_purpose] if params.has_key?(:cowriting_purpose)
|
||||
|
||||
@user.mod_merge(params[:mods]) if params[:mods]
|
||||
|
||||
# allow keyword of 'LATEST' to mean set the notification_seen_at to the most recent notification for this user
|
||||
|
|
@ -69,6 +104,9 @@ class ApiUsersController < ApiController
|
|||
@user.update_notification_seen_at params[:notification_seen_at]
|
||||
end
|
||||
|
||||
@user.update_online_presences(params[:online_presences]) if params.has_key?(:online_presences)
|
||||
@user.update_performance_samples(params[:performance_samples]) if params.has_key?(:performance_samples)
|
||||
|
||||
@user.save
|
||||
|
||||
if @user.errors.any?
|
||||
|
|
|
|||
Loading…
Reference in New Issue