VRFS-2693 VRFS-2694 wip new musician profile models
This commit is contained in:
parent
f521f3ba4c
commit
8d19e4510e
|
|
@ -1,4 +1,19 @@
|
|||
module JamRuby
|
||||
class PerformanceSample < ActiveRecord::Base
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "user_id"
|
||||
belongs_to :claimed_recording, :class_name => "JamRuby::ClaimedRecording" :foreign_key => "claimed_recording_id"
|
||||
|
||||
validates :user_type_recording_unique :if => lambda { |p| p.type == "jamkazam" }
|
||||
validates :user_type_service_unique :if => lambda { |p| p.type != "jamkazam" }
|
||||
|
||||
def user_type_recording_unique
|
||||
match = PerformanceSample.exists?(:user_id => user.id, :claimed_recording_id => self.claimed_recording_id)
|
||||
raise "You already have this JamKazam recording listed as a sample" if match
|
||||
end
|
||||
|
||||
def user_type_service_unique
|
||||
match = PerformanceSample.exists?(:user_id => user.id, :service_id => self.service_id)
|
||||
raise "You already have this #{self.type} sample listed (#{self.service_id}." if match
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -152,6 +152,9 @@ module JamRuby
|
|||
# This causes the authenticate method to be generated (among other stuff)
|
||||
#has_secure_password
|
||||
|
||||
has_many :user_presences, :class_name => "JamRuby::UserPresence"
|
||||
has_many :performance_samples, :class_name => "JamRuby::PerformanceSample"
|
||||
|
||||
before_save :create_remember_token, :if => :should_validate_password?
|
||||
before_save :stringify_avatar_info , :if => :updating_avatar
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
module JamRuby
|
||||
class UserPresence < ActiveRecord::Base
|
||||
belongs_to :user, :class_name => "JamRuby::User", :foreign_key => "user_id"
|
||||
|
||||
def self.save(user, params)
|
||||
UserPresence.create(:user => user, :type => params[:type], :username => username)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -674,6 +674,9 @@ describe User do
|
|||
|
||||
user.birth_date = Time.now - 10.years + 3.months
|
||||
user.age.should == 9
|
||||
|
||||
user.birth_date = nil
|
||||
user.age.should == "unspecified"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class ApiUsersController < ApiController
|
|||
:band_invitation_index, :band_invitation_show, :band_invitation_update, # band invitations
|
||||
:set_password, :begin_update_email, :update_avatar, :delete_avatar, :generate_filepicker_policy,
|
||||
:share_session, :share_recording,
|
||||
:affiliate_report, :audio_latency]
|
||||
:affiliate_report, :audio_latency, :profile]
|
||||
|
||||
respond_to :json
|
||||
|
||||
|
|
@ -699,6 +699,9 @@ class ApiUsersController < ApiController
|
|||
end
|
||||
end
|
||||
|
||||
def profile
|
||||
end
|
||||
|
||||
###################### RECORDINGS #######################
|
||||
# def recording_index
|
||||
# @recordings = User.recording_index(current_user, params[:id])
|
||||
|
|
|
|||
|
|
@ -335,6 +335,9 @@ SampleApp::Application.routes.draw do
|
|||
match '/users/:id/share/session/:provider' => 'api_users#share_session', :via => :get
|
||||
match '/users/:id/share/recording/:provider' => 'api_users#share_recording', :via => :get
|
||||
|
||||
#profile
|
||||
match '/users/:id/profile' => 'api_users#profile', :via => :get, :as => 'api_users_profile'
|
||||
|
||||
# session chat
|
||||
match '/chat' => 'api_chats#create', :via => :post
|
||||
match '/sessions/:music_session/chats' => 'api_chats#index', :via => :get
|
||||
|
|
|
|||
Loading…
Reference in New Issue