VRFS-80 session history
This commit is contained in:
parent
fd57f3f01e
commit
b5a031592e
|
|
@ -1,7 +1,7 @@
|
|||
class ApiUsersController < ApiController
|
||||
|
||||
before_filter :api_signed_in_user, :except => [:create, :signup_confirm, :auth_session_create]
|
||||
before_filter :auth_user, :only => [:session_settings_show, :update, :delete,
|
||||
before_filter :auth_user, :only => [:session_settings_show, :session_history_index, :session_user_history_index, :update, :delete,
|
||||
:like_create, :like_destroy, # likes
|
||||
:following_create, :following_destroy, # followings
|
||||
:recording_update, :recording_destroy, # recordings
|
||||
|
|
@ -141,6 +141,15 @@ class ApiUsersController < ApiController
|
|||
respond_with @user.my_session_settings, responder: ApiResponder
|
||||
end
|
||||
|
||||
###################### SESSION HISTORY ###################
|
||||
def session_history_index
|
||||
@session_history = @user.session_history(params[:id], params[:band_id], params[:genre])
|
||||
end
|
||||
|
||||
def session_user_history_index
|
||||
@session_user_history = @user.session_user_history(params[:id], params[:session_id])
|
||||
end
|
||||
|
||||
###################### BANDS ########################
|
||||
def band_index
|
||||
@bands = User.band_index(params[:id])
|
||||
|
|
@ -260,7 +269,6 @@ class ApiUsersController < ApiController
|
|||
nil,
|
||||
params[:message])
|
||||
|
||||
@user = current_user
|
||||
respond_with @friend_request, responder: ApiResponder, :status => 201, :location => api_friend_request_detail_url(@user, @friend_request)
|
||||
end
|
||||
|
||||
|
|
@ -289,7 +297,6 @@ class ApiUsersController < ApiController
|
|||
|
||||
##################### BAND INVITATIONS ##################
|
||||
def band_invitation_index
|
||||
@user = current_user
|
||||
@invitations = @user.received_band_invitations
|
||||
respond_with @invitations, responder: ApiResponder, :status => 200
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
object @music_session
|
||||
|
||||
attributes :id, :description, :musician_access, :approval_required, :fan_access, :fan_chat, :band_id
|
||||
attributes :id, :description, :musician_access, :approval_required, :fan_access, :fan_chat, :band_id, :user_id
|
||||
|
||||
node :genres do |item|
|
||||
item.genres.map(&:id)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,7 @@
|
|||
object @session_history
|
||||
|
||||
attributes :music_session_id, :user_id, :description, :band_id, :genres
|
||||
|
||||
child :music_session_user_histories => :participants do
|
||||
attributes :client_id, :user_id
|
||||
end
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
object @session_user_history
|
||||
|
||||
attributes :music_session_id, :user_id, :client_id
|
||||
|
|
@ -76,6 +76,10 @@ SampleApp::Application.routes.draw do
|
|||
# session settings
|
||||
match '/users/:id/session_settings' => 'api_users#session_settings_show', :via => :get
|
||||
|
||||
# session history
|
||||
match '/users/:id/session_history' => 'api_users#session_history_index', :via => :get
|
||||
match '/users/:id/session_history/:session_id/users' => 'api_users#session_user_history_index', :via => :get
|
||||
|
||||
# user bands
|
||||
match '/users/:id/bands' => 'api_users#band_index', :via => :get
|
||||
|
||||
|
|
@ -123,7 +127,6 @@ SampleApp::Application.routes.draw do
|
|||
match '/users/:id/recordings' => 'api_users#recording_create', :via => :post
|
||||
match '/users/:id/recordings/:recording_id' => 'api_users#recording_update', :via => :post
|
||||
match '/users/:id/recordings/:recording_id' => 'api_users#recording_destroy', :via => :delete
|
||||
|
||||
|
||||
# bands
|
||||
match '/bands' => 'api_bands#index', :via => :get
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class MusicSessionManager < BaseManager
|
|||
music_session.band = band
|
||||
music_session.legal_terms = legal_terms
|
||||
|
||||
genres = genres
|
||||
#genres = genres
|
||||
@log.debug "Genres class: " + genres.class.to_s()
|
||||
|
||||
unless genres.nil?
|
||||
|
|
@ -37,7 +37,11 @@ class MusicSessionManager < BaseManager
|
|||
music_session.save
|
||||
|
||||
unless music_session.errors.any?
|
||||
# save session parameters for next session
|
||||
User.save_session_settings(user, music_session)
|
||||
|
||||
# save session history
|
||||
MusicSessionHistory.save(music_session)
|
||||
|
||||
# auto-join this user into the newly created session
|
||||
connection = ConnectionManager.new.join_music_session(user.id, client_id, music_session.id, true, tracks)
|
||||
|
|
@ -78,6 +82,9 @@ class MusicSessionManager < BaseManager
|
|||
end
|
||||
|
||||
music_session.save
|
||||
|
||||
# save session history (only thing that could change is description)
|
||||
MusicSessionHistory.save(music_session)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,6 @@ describe "Music Session API ", :type => :api do
|
|||
|
||||
get '/api/sessions.json'
|
||||
music_sessions = JSON.parse(last_response.body)
|
||||
|
||||
music_session = music_sessions[0]
|
||||
music_session["id"].should == music_sessions[0]["id"]
|
||||
music_session["musician_access"].should be_true
|
||||
|
|
@ -78,6 +77,17 @@ describe "Music Session API ", :type => :api do
|
|||
session_settings["fan_chat"].should be_true
|
||||
session_settings["fan_access"].should be_true
|
||||
|
||||
# test session history
|
||||
get '/api/users/' + user.id + '/session_history.json'
|
||||
last_response.status.should == 200
|
||||
session_history = JSON.parse(last_response.body)
|
||||
session_history[0]["user_id"].to_s.should == user.id
|
||||
session_history[0]["band_id"].should == music_session["band_id"]
|
||||
session_history[0]["description"].should == music_session["description"]
|
||||
|
||||
get '/api/users/' + user.id + '/session_history/' + music_session["id"] + '/users.json'
|
||||
#puts last_response.body
|
||||
|
||||
# test Track-specific APIs
|
||||
get "/api/sessions/#{music_session["id"]}/tracks.json", "CONTENT_TYPE" => 'application/json'
|
||||
last_response.status.should == 200
|
||||
|
|
|
|||
Loading…
Reference in New Issue