diff --git a/ruby/lib/jam_ruby/models/music_session.rb b/ruby/lib/jam_ruby/models/music_session.rb index a2e353ede..f54f57b6f 100644 --- a/ruby/lib/jam_ruby/models/music_session.rb +++ b/ruby/lib/jam_ruby/models/music_session.rb @@ -250,7 +250,11 @@ module JamRuby query end - def self.scheduled_rsvp user + # if only_approved is set, then only return sessions where the current user has been chosen + def self.scheduled_rsvp(user, only_approved = false) + + filter_approved = only_approved ? 'AND rrrs.chosen = true' : '' + MusicSession.where(%Q{music_sessions.canceled = FALSE AND (music_sessions.scheduled_start is NULL OR music_sessions.scheduled_start > NOW() - '4 hour'::INTERVAL) AND music_sessions.id in ( @@ -260,7 +264,7 @@ module JamRuby select rrrs.rsvp_slot_id from rsvp_requests rr inner join rsvp_requests_rsvp_slots rrrs on rr.id = rrrs.rsvp_request_id - where rr.user_id = '#{user.id}' + where rr.user_id = '#{user.id}' #{filter_approved} ) )} ).order(:scheduled_start) @@ -708,6 +712,9 @@ module JamRuby [music_sessions, user_scores] end + def self.upcoming_sessions + + end # converts the passed scheduled_start into the database timezone using the specified timezone offset. # timezone comes in as TIMEZONE DISPLAY, TIMEZONE ID def self.parse_scheduled_start(scheduled_start, timezone_param) diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index de284dfce..e510108bd 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -291,6 +291,11 @@ module JamRuby self.music_sessions.size end + # count up any session you are RSVP'ed to + def upcoming_session_count + MusicSession.scheduled_rsvp(self, true).length + end + def joined_score return nil unless has_attribute?(:score) a = read_attribute(:score) diff --git a/ruby/spec/jam_ruby/models/music_session_spec.rb b/ruby/spec/jam_ruby/models/music_session_spec.rb index bf78f5cb1..7a7838de3 100644 --- a/ruby/spec/jam_ruby/models/music_session_spec.rb +++ b/ruby/spec/jam_ruby/models/music_session_spec.rb @@ -741,6 +741,16 @@ describe MusicSession do music_session_1.save! MusicSession.scheduled_rsvp(creator_1).should == [] end + + it "only show approved sessions" do + MusicSession.scheduled_rsvp(creator_1, true).should == [music_session_1] + end + + it "does not show unchosen" do + music_session_1.rsvp_slots[0].rsvp_requests_rsvp_slots[0].chosen = false + music_session_1.rsvp_slots[0].rsvp_requests_rsvp_slots[0].save! + MusicSession.scheduled_rsvp(creator_1, true).should == [] + end end end end diff --git a/web/app/assets/javascripts/accounts.js b/web/app/assets/javascripts/accounts.js index 7d5d1eda1..c5135f8d4 100644 --- a/web/app/assets/javascripts/accounts.js +++ b/web/app/assets/javascripts/accounts.js @@ -24,15 +24,26 @@ $('#account-content-scroller form .error').removeClass("error") } + function summarizeSession(userDetail) { + if(userDetail.upcoming_session_count > 0) { + return 'You are scheduled to play in ' + userDetail.upcoming_session_count + ' sessions' + } + else { + return 'You are not scheduled to play in any sessions' + } + } + function populateAccount(userDetail) { var validProfiles = prettyPrintAudioProfiles(context.JK.getGoodConfigMap()); var invalidProfiles = prettyPrintAudioProfiles(context.JK.getBadConfigMap()); + var sessionSummary = summarizeSession(userDetail); var $template = $(context._.template($('#template-account-main').html(), { email: userDetail.email, name: userDetail.name, location : userDetail.location, + session : sessionSummary, instruments : prettyPrintInstruments(userDetail.instruments), photoUrl : context.JK.resolveAvatarUrl(userDetail.photo_url), validProfiles : validProfiles, diff --git a/web/app/assets/stylesheets/client/account.css.scss b/web/app/assets/stylesheets/client/account.css.scss index d6e0f1948..a24d1c05a 100644 --- a/web/app/assets/stylesheets/client/account.css.scss +++ b/web/app/assets/stylesheets/client/account.css.scss @@ -15,6 +15,10 @@ overflow-x: hidden; padding: 10px 35px; white-space: nowrap; + + .button-orange { + width:45px; + } } h4 { diff --git a/web/app/assets/stylesheets/client/screen_common.css.scss b/web/app/assets/stylesheets/client/screen_common.css.scss index 06e3cf709..0e7252a72 100644 --- a/web/app/assets/stylesheets/client/screen_common.css.scss +++ b/web/app/assets/stylesheets/client/screen_common.css.scss @@ -184,6 +184,7 @@ small, .small {font-size:11px;} color:#ccc; text-decoration:none; line-height:12px; + text-align:center; } .button-grey:hover { @@ -204,6 +205,7 @@ small, .small {font-size:11px;} color:#FC9; text-decoration:none; line-height:12px; + text-align:center; &.disabled { background-color: transparent; diff --git a/web/app/views/api_users/show.rabl b/web/app/views/api_users/show.rabl index 02be0b8a5..eba9115d9 100644 --- a/web/app/views/api_users/show.rabl +++ b/web/app/views/api_users/show.rabl @@ -1,6 +1,6 @@ object @user -attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :follower_count, :following_count, :recording_count, :session_count, :biography, :favorite_count, :audio_latency +attributes :id, :first_name, :last_name, :name, :city, :state, :country, :location, :online, :photo_url, :musician, :gender, :birth_date, :internet_service_provider, :friend_count, :liker_count, :like_count, :follower_count, :following_count, :recording_count, :session_count, :biography, :favorite_count, :audio_latency, :upcoming_session_count if @user.musician? node :location do @user.location end diff --git a/web/app/views/clients/_account.html.erb b/web/app/views/clients/_account.html.erb index 83c97c784..303e217e4 100644 --- a/web/app/views/clients/_account.html.erb +++ b/web/app/views/clients/_account.html.erb @@ -30,9 +30,10 @@