fix create session flow, rsvp
This commit is contained in:
parent
8baebfd105
commit
af06127403
|
|
@ -178,3 +178,5 @@ update_ams_index_2.sql
|
|||
sms_index.sql
|
||||
music_sessions_description_search.sql
|
||||
rsvp_slots_prof_level.sql
|
||||
add_file_name_music_notation.sql
|
||||
change_scheduled_start_music_session.sql
|
||||
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE music_notations ADD COLUMN file_name VARCHAR(255);
|
||||
|
|
@ -0,0 +1 @@
|
|||
ALTER TABLE music_sessions ALTER COLUMN scheduled_start TYPE timestamp without time zone;
|
||||
|
|
@ -4,7 +4,7 @@ module JamRuby
|
|||
|
||||
self.primary_key = 'id'
|
||||
|
||||
attr_accessible :file_url, :size
|
||||
attr_accessible :file_url, :size, :file_name
|
||||
|
||||
belongs_to :user, :class_name => "JamRuby::User", foreign_key: :user_id
|
||||
belongs_to :music_session, :class_name => "JamRuby::MusicSession", foreign_key: :music_session_id
|
||||
|
|
@ -30,10 +30,6 @@ module JamRuby
|
|||
s3_manager.sign_url(self[:file_url], {:expires => expiration_time, :secure => false})
|
||||
end
|
||||
|
||||
def filename
|
||||
File.basename(self.file_url)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def delete_s3_files
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ module JamRuby
|
|||
attr_accessor :legal_terms, :language_description, :scheduled_start_time, :access_description
|
||||
|
||||
attr_accessor :approved_rsvps, :open_slots, :pending_invitations
|
||||
attr_accessor :approved_rsvps_detail, :open_slots_detail
|
||||
|
||||
self.table_name = "music_sessions"
|
||||
|
||||
|
|
@ -252,6 +253,7 @@ module JamRuby
|
|||
ms.scheduled_start = options[:start]
|
||||
ms.scheduled_duration = options[:duration].to_i * 1.minutes if options[:duration]
|
||||
ms.recurring_mode = options[:recurring_mode] if options[:recurring_mode]
|
||||
ms.timezone = options[:timezone] if options[:timezone]
|
||||
ms.legal_terms = true
|
||||
ms.creator = user
|
||||
|
||||
|
|
@ -271,13 +273,13 @@ module JamRuby
|
|||
|
||||
ms.rsvp_slots << rsvp
|
||||
|
||||
if !rs[:approve].nil? && rs[:approve] == true
|
||||
if rs[:approve] == true
|
||||
self_rsvp_slot_ids.push rsvp.id
|
||||
else
|
||||
rsvp_slot_ids.push rsvp.id
|
||||
end
|
||||
end if options[:rsvp_slots]
|
||||
RsvpRequest.create({session_id: ms.id, rsvp_slots: self_rsvp_slot_ids, :autoapprove => true}, user).map(&:id)
|
||||
RsvpRequest.create({session_id: ms.id, rsvp_slots: self_rsvp_slot_ids, :autoapprove => true}, user)
|
||||
|
||||
options[:invitations].each do |invite_id|
|
||||
invitation = Invitation.new
|
||||
|
|
@ -491,6 +493,38 @@ module JamRuby
|
|||
users_collapsed_instruments
|
||||
end
|
||||
|
||||
def approved_rsvps_detail
|
||||
users = User.find_by_sql(%Q{select u.id, u.photo_url, u.first_name, u.last_name, rs.instrument_id, ii.description, rs.proficiency_level
|
||||
from rsvp_slots rs
|
||||
inner join rsvp_requests_rsvp_slots rrrs on rrrs.rsvp_slot_id = rs.id
|
||||
inner join rsvp_requests rr on rrrs.rsvp_request_id = rr.id
|
||||
inner join instruments ii on ii.id = rs.instrument_id
|
||||
inner join users u on u.id = rr.user_id
|
||||
where rrrs.chosen = true and rs.music_session_id = '#{self.id}'
|
||||
order by u.id}
|
||||
)
|
||||
|
||||
users_collapsed_instruments = []
|
||||
user = User.new
|
||||
|
||||
# build User array with instruments collapsed
|
||||
users.each_with_index do |u, index|
|
||||
if index == 0 || users[index].id != users[index-1].id
|
||||
user = User.new
|
||||
user.id = u.id
|
||||
user.photo_url = u.photo_url
|
||||
user.first_name = u.first_name
|
||||
user.last_name = u.last_name
|
||||
user.instrument_list = [{id: u.instrument_id, desc: u.description, level: u.proficiency_level}]
|
||||
users_collapsed_instruments << user
|
||||
else
|
||||
user.instrument_list << {id: u.instrument_id, desc: u.description, level: u.proficiency_level}
|
||||
end
|
||||
end
|
||||
|
||||
users_collapsed_instruments
|
||||
end
|
||||
|
||||
# get all slots for this session and perform a set difference with all chosen slots;
|
||||
# this will return those that are not filled yet
|
||||
def open_slots
|
||||
|
|
@ -507,6 +541,22 @@ module JamRuby
|
|||
)
|
||||
end
|
||||
|
||||
def open_slots_detail
|
||||
RsvpSlot.find_by_sql(%Q{select rs.*, ii.description
|
||||
from rsvp_slots rs
|
||||
inner join instruments ii on ii.id = rs.instrument_id
|
||||
where rs.music_session_id = '#{self.id}'
|
||||
except
|
||||
select distinct rs.*, iii.description
|
||||
from rsvp_slots rs
|
||||
inner join instruments iii on iii.id = rs.instrument_id
|
||||
inner join rsvp_requests_rsvp_slots rrrs on rrrs.rsvp_slot_id = rs.id
|
||||
where rs.music_session_id = '#{self.id}'
|
||||
and rrrs.chosen = true
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
# retrieve users that have invitations but have not submitted an RSVP request for this session
|
||||
def pending_invitations
|
||||
User.find_by_sql(%Q{select u.id, u.email, u.photo_url, u.first_name, u.last_name
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
|
||||
var ONE_HOUR = 3600 * 1000;
|
||||
var ONE_MINUTE = 60 * 1000;
|
||||
var ONE_DAY = ONE_HOUR * 24;
|
||||
|
||||
var defaultTimeArray = ["12:00 AM", "12:30 AM", "01:00 AM", "01:30 AM", "02:00 AM", "02:30 AM",
|
||||
"03:00 AM", "03:30 AM", "04:00 AM", "04:30 AM", "05:00 AM", "05:30 AM", "06:00 AM", "06:30 AM",
|
||||
|
|
@ -60,9 +61,12 @@
|
|||
"11:00 PM", "11:30 PM"];
|
||||
|
||||
var proficiencyDescriptionMap = {
|
||||
"1": "Beginner",
|
||||
"2": "Intermediate",
|
||||
"3": "Expert"
|
||||
"0": "Any",
|
||||
"1": "Beg",
|
||||
"2": "Beg/Int",
|
||||
"3": "Int",
|
||||
"4": "Int/Adv",
|
||||
"5": "Adv"
|
||||
};
|
||||
|
||||
function afterLoadScheduledSessions(sessionList) {
|
||||
|
|
@ -126,7 +130,7 @@
|
|||
function afterLoadUserDetail(userDetail) {
|
||||
var userInstruments = [];
|
||||
$.each(userDetail.instruments, function(index, userInstrument) {
|
||||
userInstrument.level = proficiencyDescriptionMap[userInstrument.proficiency_level];
|
||||
userInstrument.level = userInstrument.proficiency_level;
|
||||
userInstruments.push(userInstrument);
|
||||
})
|
||||
|
||||
|
|
@ -229,7 +233,37 @@
|
|||
$('#session-invited-disp').html(sessionInvitedString);
|
||||
|
||||
if (createSessionSettings.createType == 'start-scheduled') {
|
||||
var session = scheduledSessions[createSessionSettings.selectedSessionId];
|
||||
if (session.approved_rsvps_detail.length > 0) {
|
||||
var instruments_me = [];
|
||||
$.each(session.approved_rsvps_detail, function(index, user) {
|
||||
if (user.id == context.JK.currentUserId) {
|
||||
$.each(user.instrument_list, function(index, instrument) {
|
||||
instruments_me.push(instrument.desc);
|
||||
});
|
||||
}
|
||||
});
|
||||
$('#session-instruments-me-disp').html(instruments_me.join(', '));
|
||||
}
|
||||
|
||||
if (session.open_slots_detail.length > 0) {
|
||||
var instruments_rsvp = {};
|
||||
$.each(session.open_slots_detail, function(index, slot) {
|
||||
if (instruments_rsvp[slot.description]) {
|
||||
instruments_rsvp[slot.description]["count"] = instruments_rsvp[slot.description]["count"] + 1;
|
||||
}
|
||||
else {
|
||||
instrumens_rsvp[slot.description] = {"count": 1, "level": slot.proficiency_desc};
|
||||
}
|
||||
});
|
||||
|
||||
var instruments_rsvp_arr = $.makeArray(instruments_rsvp);
|
||||
var instruments_str_arr = [];
|
||||
$.map(instruments_rsvp_arr, function(val, i) {
|
||||
instruments_str_arr.push(i + ' (' + val.count + ') (' + val.level + ')');
|
||||
})
|
||||
$('#session-instruments-rsvp-disp').html(instruments_str_arr.join(', '));
|
||||
}
|
||||
}
|
||||
else {
|
||||
var instruments_me = [];
|
||||
|
|
@ -240,7 +274,7 @@
|
|||
|
||||
var instruments_rsvp = [];
|
||||
$.each(instrumentRSVP.getSelectedInstruments(), function(index, instrument) {
|
||||
instruments_rsvp.push(instrument.name + ' (' + instrument.count + ') (' + instrument.level + ')');
|
||||
instruments_rsvp.push(instrument.name + ' (' + instrument.count + ') (' + proficiencyDescriptionMap[instrument.level] + ')');
|
||||
});
|
||||
$('#session-instruments-rsvp-disp').html(instruments_rsvp.join(', '));
|
||||
}
|
||||
|
|
@ -481,6 +515,9 @@
|
|||
data.start = createSessionSettings.startDate + ' ' + createSessionSettings.startTime;
|
||||
var endDate = new Date(createSessionSettings.startDate + ' ' + createSessionSettings.endTime);
|
||||
data.duration = (endDate - new Date(data.start)) / ONE_MINUTE;
|
||||
if (createSessionSettings.endTime == defaultTimeArray[0]) {
|
||||
data.duration += ONE_DAY / ONE_MINUTE;
|
||||
}
|
||||
}
|
||||
data.invitations = inviteMusiciansUtil.getInvitedFriends();
|
||||
data.recurring_mode = createSessionSettings.recurring_mode.value;
|
||||
|
|
@ -501,7 +538,7 @@
|
|||
var slot = {};
|
||||
slot.instrument_id = instrument.id;
|
||||
slot.proficiency_level = instrument.level;
|
||||
slot.approve = true;
|
||||
slot.approve = false;
|
||||
data.rsvp_slots.push(slot);
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ class ApiMusicNotationsController < ApiController
|
|||
params[:files].each do |file|
|
||||
music_notation = MusicNotation.new
|
||||
music_notation.file_url = file
|
||||
music_notation.file_name = file.original_filename
|
||||
music_notation.user = current_user
|
||||
music_notation.save
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,14 @@ else
|
|||
end
|
||||
}
|
||||
|
||||
child({:approved_rsvps_detail => :approved_rsvps_detail}) {
|
||||
attributes :id, :photo_url, :first_name, :last_name, :instrument_list
|
||||
}
|
||||
|
||||
child({:open_slots_detail => :open_slots_detail}) {
|
||||
attributes :id, :instrument_id, :proficiency_level, :proficiency_desc, :description
|
||||
}
|
||||
|
||||
child({:open_slots => :open_slots}) {
|
||||
attributes :id, :instrument_id, :proficiency_level, :proficiency_desc
|
||||
}
|
||||
|
|
|
|||
|
|
@ -465,9 +465,9 @@
|
|||
</div>
|
||||
<div class="right ib w45 mb5">
|
||||
<select class="f12" session-instrument-id="{value}">
|
||||
<option value="Beginner">Beginner</option>
|
||||
<option value="Intermediate">Intermediate</option>
|
||||
<option value="Expert">Expert</option>
|
||||
<option value="1">Beginner</option>
|
||||
<option value="2">Intermediate</option>
|
||||
<option value="3">Expert</option>
|
||||
</select>
|
||||
</div>
|
||||
</script>
|
||||
|
|
@ -488,12 +488,12 @@
|
|||
<option value="4">4</option>
|
||||
</select>
|
||||
<select class="f12 rsvp-level" session-instrument-id="{value}">
|
||||
<option value="Any">Any Skill Level</option>
|
||||
<option value="Beg">Beginner</option>
|
||||
<option value="Beg/Int">Beginner to Intermediate</option>
|
||||
<option value="Int">Intermediate</option>
|
||||
<option value="Int/Adv">Intermediate to Advanced</option>
|
||||
<option value="Adv">Advanced</option>
|
||||
<option value="0">Any Skill Level</option>
|
||||
<option value="1">Beginner</option>
|
||||
<option value="2">Beginner to Intermediate</option>
|
||||
<option value="3">Intermediate</option>
|
||||
<option value="4">Intermediate to Advanced</option>
|
||||
<option value="5">Advanced</option>
|
||||
</select>
|
||||
</div>
|
||||
</script>
|
||||
|
|
@ -0,0 +1,115 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "Create Session Flow", :js => true, :type => :feature, :capybara_feature => true do
|
||||
context "create session flow" do
|
||||
let(:user1) { FactoryGirl.create(:user) }
|
||||
let(:user2) { FactoryGirl.create(:user) }
|
||||
|
||||
before(:each) do
|
||||
MusicSession.delete_all
|
||||
ActiveMusicSession.delete_all
|
||||
|
||||
sign_in_poltergeist(user1)
|
||||
in_client(user1) do
|
||||
visit "/client#/createSession"
|
||||
end
|
||||
end
|
||||
|
||||
describe "step 1" do
|
||||
it "initial status" do
|
||||
in_client(user1) do
|
||||
find('.session-step-title', text: 'When Is Your Session?')
|
||||
find('#session-when-start-scheduled[checked="checked"]')
|
||||
find('div#scheduled-session-not-found')
|
||||
find('div[info-id="start-scheduled"]')
|
||||
page.should have_css(".session-stepnumber", :count => 2)
|
||||
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
|
||||
end
|
||||
end
|
||||
|
||||
it "select option for scheduling a session" do
|
||||
in_client(user1) do
|
||||
find('li[create-type="schedule-future"] ins').trigger(:click)
|
||||
find('div[info-id="scheduled-future"]')
|
||||
page.should have_css(".session-stepnumber", :count => 5)
|
||||
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
|
||||
find('div#schedule-future-wrapper')
|
||||
find('h3', text: 'When will the session happen?')
|
||||
find('input#session-start-date')
|
||||
find('select#start-time-list')
|
||||
find('select#end-time-list')
|
||||
find('select#timezone-list')
|
||||
find('select#recurring-mode-list')
|
||||
end
|
||||
end
|
||||
|
||||
it "select option for scheduling session after others RSVP" do
|
||||
in_client(user1) do
|
||||
find('li[create-type="rsvp"] ins').trigger(:click)
|
||||
find('div[info-id="rsvp"]')
|
||||
page.should have_css(".session-stepnumber", :count => 5)
|
||||
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
|
||||
end
|
||||
end
|
||||
|
||||
it "select option for starting session right now" do
|
||||
in_client(user1) do
|
||||
find('li[create-type="immediately"] ins').trigger(:click)
|
||||
find('div[info-id="immediately"]')
|
||||
page.should have_css(".session-stepnumber", :count => 5)
|
||||
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
|
||||
end
|
||||
end
|
||||
|
||||
it "select option for starting quick session" do
|
||||
in_client(user1) do
|
||||
find('li[create-type="quick-start"] ins').trigger(:click)
|
||||
find('div[info-id="quick-start"]')
|
||||
page.should have_css(".session-stepnumber", :count => 2)
|
||||
page.should have_css(".session-stepnumber .session-stepactive", :count => 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "step 2" do
|
||||
before(:each) do
|
||||
in_client(user1) do
|
||||
find('li[create-type="schedule-future"] ins').trigger(:click)
|
||||
find('.btn-next').trigger(:click)
|
||||
end
|
||||
end
|
||||
|
||||
it "initial status" do
|
||||
in_client(user1) do
|
||||
find('.session-step-title', text: 'What Are You Playing?')
|
||||
end
|
||||
end
|
||||
|
||||
it "validates genre, name and description" do
|
||||
in_client(user1) do
|
||||
find('.btn-next').trigger(:click)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "step 3" do
|
||||
before(:each) do
|
||||
end
|
||||
|
||||
it "initial status" do
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
describe "step 4" do
|
||||
before(:each) do
|
||||
end
|
||||
end
|
||||
|
||||
describe "step 5" do
|
||||
before(:each) do
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue