* VRFS-1861 - show something useful in the session section of the account screen

This commit is contained in:
Seth Call 2014-07-12 08:55:58 -05:00
parent 68f253080c
commit 14dad29c59
8 changed files with 44 additions and 4 deletions

View File

@ -250,7 +250,11 @@ module JamRuby
query query
end 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 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.scheduled_start is NULL OR music_sessions.scheduled_start > NOW() - '4 hour'::INTERVAL) AND
music_sessions.id in ( music_sessions.id in (
@ -260,7 +264,7 @@ module JamRuby
select rrrs.rsvp_slot_id select rrrs.rsvp_slot_id
from rsvp_requests rr from rsvp_requests rr
inner join rsvp_requests_rsvp_slots rrrs on rr.id = rrrs.rsvp_request_id 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) ).order(:scheduled_start)
@ -708,6 +712,9 @@ module JamRuby
[music_sessions, user_scores] [music_sessions, user_scores]
end end
def self.upcoming_sessions
end
# converts the passed scheduled_start into the database timezone using the specified timezone offset. # converts the passed scheduled_start into the database timezone using the specified timezone offset.
# timezone comes in as TIMEZONE DISPLAY, TIMEZONE ID # timezone comes in as TIMEZONE DISPLAY, TIMEZONE ID
def self.parse_scheduled_start(scheduled_start, timezone_param) def self.parse_scheduled_start(scheduled_start, timezone_param)

View File

@ -291,6 +291,11 @@ module JamRuby
self.music_sessions.size self.music_sessions.size
end end
# count up any session you are RSVP'ed to
def upcoming_session_count
MusicSession.scheduled_rsvp(self, true).length
end
def joined_score def joined_score
return nil unless has_attribute?(:score) return nil unless has_attribute?(:score)
a = read_attribute(:score) a = read_attribute(:score)

View File

@ -741,6 +741,16 @@ describe MusicSession do
music_session_1.save! music_session_1.save!
MusicSession.scheduled_rsvp(creator_1).should == [] MusicSession.scheduled_rsvp(creator_1).should == []
end 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 end
end end

View File

@ -24,15 +24,26 @@
$('#account-content-scroller form .error').removeClass("error") $('#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) { function populateAccount(userDetail) {
var validProfiles = prettyPrintAudioProfiles(context.JK.getGoodConfigMap()); var validProfiles = prettyPrintAudioProfiles(context.JK.getGoodConfigMap());
var invalidProfiles = prettyPrintAudioProfiles(context.JK.getBadConfigMap()); var invalidProfiles = prettyPrintAudioProfiles(context.JK.getBadConfigMap());
var sessionSummary = summarizeSession(userDetail);
var $template = $(context._.template($('#template-account-main').html(), { var $template = $(context._.template($('#template-account-main').html(), {
email: userDetail.email, email: userDetail.email,
name: userDetail.name, name: userDetail.name,
location : userDetail.location, location : userDetail.location,
session : sessionSummary,
instruments : prettyPrintInstruments(userDetail.instruments), instruments : prettyPrintInstruments(userDetail.instruments),
photoUrl : context.JK.resolveAvatarUrl(userDetail.photo_url), photoUrl : context.JK.resolveAvatarUrl(userDetail.photo_url),
validProfiles : validProfiles, validProfiles : validProfiles,

View File

@ -15,6 +15,10 @@
overflow-x: hidden; overflow-x: hidden;
padding: 10px 35px; padding: 10px 35px;
white-space: nowrap; white-space: nowrap;
.button-orange {
width:45px;
}
} }
h4 { h4 {

View File

@ -184,6 +184,7 @@ small, .small {font-size:11px;}
color:#ccc; color:#ccc;
text-decoration:none; text-decoration:none;
line-height:12px; line-height:12px;
text-align:center;
} }
.button-grey:hover { .button-grey:hover {
@ -204,6 +205,7 @@ small, .small {font-size:11px;}
color:#FC9; color:#FC9;
text-decoration:none; text-decoration:none;
line-height:12px; line-height:12px;
text-align:center;
&.disabled { &.disabled {
background-color: transparent; background-color: transparent;

View File

@ -1,6 +1,6 @@
object @user 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? if @user.musician?
node :location do @user.location end node :location do @user.location end

View File

@ -30,9 +30,10 @@
<h2>sessions: </h2> <h2>sessions: </h2>
</div> </div>
<div class="account-mid sessions"> <div class="account-mid sessions">
{{data.session}}
</div> </div>
<div class="right"> <div class="right">
<a id="account-scheduled-sessions-link" href="#" class="button-orange">UPDATE</a> <a id="account-scheduled-sessions-link" href="#" class="button-orange">VIEW</a>
</div> </div>
<br clear="all" /> <br clear="all" />
<hr/> <hr/>