diff --git a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb
index 6a5d5ec92..150942542 100644
--- a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb
+++ b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb
@@ -222,7 +222,7 @@
subject = "Session Invitation"
unique_args = {:type => "scheduled_session_invitation"}
@body = msg
- @session_name = session.description
+ @session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@@ -241,7 +241,7 @@
subject = "Session RSVP"
unique_args = {:type => "scheduled_session_rsvp"}
@body = msg
- @session_name = session.description
+ @session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@@ -260,7 +260,7 @@
subject = "Session RSVP Approved"
unique_args = {:type => "scheduled_session_rsvp_approved"}
@body = msg
- @session_name = session.description
+ @session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@@ -279,7 +279,7 @@
subject = "Session RSVP Cancelled"
unique_args = {:type => "scheduled_session_rsvp_cancelled"}
@body = msg
- @session_name = session.description
+ @session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@@ -298,7 +298,7 @@
subject = "Your Session RSVP Cancelled"
unique_args = {:type => "scheduled_session_rsvp_cancelled_org"}
@body = msg
- @session_name = session.description
+ @session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@@ -317,7 +317,7 @@
subject = "Session Cancelled"
unique_args = {:type => "scheduled_session_cancelled"}
@body = msg
- @session_name = session.description
+ @session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@@ -336,7 +336,7 @@
subject = "Session Rescheduled"
unique_args = {:type => "scheduled_session_rescheduled"}
@body = msg
- @session_name = session.description
+ @session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@@ -355,7 +355,7 @@
subject = "Session Rescheduled"
unique_args = {:type => "scheduled_session_reminder"}
@body = msg
- @session_name = session.description
+ @session_name = session.name
@session_date = session.scheduled_start
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
sendgrid_category "Notification"
@@ -374,7 +374,7 @@
subject = "New Session Comment"
unique_args = {:type => "scheduled_session_comment"}
@body = msg
- @session_name = session.description
+ @session_name = session.name
@session_date = session.scheduled_start
@comment = comment
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
diff --git a/ruby/lib/jam_ruby/models/rsvp_request.rb b/ruby/lib/jam_ruby/models/rsvp_request.rb
index 9c1f9da48..a949f9306 100644
--- a/ruby/lib/jam_ruby/models/rsvp_request.rb
+++ b/ruby/lib/jam_ruby/models/rsvp_request.rb
@@ -42,8 +42,8 @@ module JamRuby
# verify invitation exists for this user and session
invitation = Invitation.where("music_session_id = ? AND receiver_id = ?", music_session.id, user.id)
- if invitation.blank?
- raise PermissionError, "Only a session invitee can create an RSVP."
+ if invitation.blank? && !music_session.open_rsvps
+ raise PermissionError, "Only a session invitee can create an RSVP for this session."
end
# verify slot IDs exist in request
@@ -56,6 +56,7 @@ module JamRuby
@rsvp.user = user
slot_ids = params[:rsvp_slots]
+
instruments = []
# for each slot requested, do the following:
diff --git a/web/app/assets/javascripts/jam_rest.js b/web/app/assets/javascripts/jam_rest.js
index 824e4cd2b..de51572e0 100644
--- a/web/app/assets/javascripts/jam_rest.js
+++ b/web/app/assets/javascripts/jam_rest.js
@@ -135,11 +135,11 @@
});
}
- function submitRsvpRequest(sessionId) {
+ function submitRsvpRequest(sessionId, slotIds) {
return $.ajax({
url: '/api/rsvp_requests',
type: "POST",
- data : JSON.stringify({"session_id": sessionId}),
+ data : JSON.stringify({"session_id": sessionId, "rsvp_slots": slotIds}),
dataType : 'json',
contentType: 'application/json'
});
diff --git a/web/app/assets/javascripts/rsvpSubmitDialog.js b/web/app/assets/javascripts/rsvpSubmitDialog.js
index 1bb5d4a32..2f6c49d00 100644
--- a/web/app/assets/javascripts/rsvpSubmitDialog.js
+++ b/web/app/assets/javascripts/rsvpSubmitDialog.js
@@ -38,7 +38,7 @@
var instrumentTitleCase = context.JK.toTitleCase(instrument);
// var instrumentTitleCase = instrument.charAt(0).toUpperCase() + instrument.substr(1).toLowerCase();
// var instTitleCase = val.instrument_id.charAt(0).toUpperCase() + context.val.instrument_id.charAt(0)
- $('.rsvp-instruments', $screen).append('' + instrumentTitleCase + "
");
+ $('.rsvp-instruments', $screen).append('' + instrumentTitleCase + "
");
});
}
else {
@@ -59,10 +59,22 @@
}
function events() {
+ $("#btnSubmit").unbind('click');
$("#btnSubmit").click(function(e) {
- rest.submitRsvpRequest(sessionId)
+ e.preventDefault();
+ var slotIds = [];
+ $("input:checked", '.rsvp-instruments').each(function(index) {
+ slotIds.push($(this).val());
+ });
+
+ if (slotIds.length === 0) {
+ $('.error', $screen).show();
+ return;
+ }
+
+ var error = false;
+ rest.submitRsvpRequest(sessionId, slotIds)
.done(function(response) {
-
var comment = $.trim($('#txtComment', $screen).val());
if (comment.length > 0) {
rest.addSessionInfoComment(sessionId, comment)
@@ -70,15 +82,22 @@
})
.fail(function(xhr) {
-
+ error = true;
+ $('.error', $screen).html("Unexpected error occurred while saving message (" + xhr.status + ")");
+ $('.error', $screen).show();
});
}
-
- app.layout.cDialog('rsvp-submit-dialog');
})
.fail(function(xhr) {
-
+ error = true;
+ $('.error', $screen).html("Unexpected error occurred while saving RSVP request (" + xhr.status + ")");
+ $('.error', $screen).show();
});
+
+ if (!error) {
+ app.layout.closeDialog('rsvp-submit-dialog');
+ $("#btnSubmit").trigger("rsvpSubmitEvent");
+ }
});
}
diff --git a/web/app/assets/javascripts/web/scheduled_session.js b/web/app/assets/javascripts/web/scheduled_session.js
index ff3792ede..857b47e02 100644
--- a/web/app/assets/javascripts/web/scheduled_session.js
+++ b/web/app/assets/javascripts/web/scheduled_session.js
@@ -92,6 +92,10 @@
$("#txtSessionComment").blur();
}
});
+
+ $(document).on("rsvpSubmitEvent", function() {
+ location.reload();
+ });
}
this.initialize = initialize;
diff --git a/web/app/assets/stylesheets/client/jamkazam.css.scss b/web/app/assets/stylesheets/client/jamkazam.css.scss
index 92d551f31..1610a3345 100644
--- a/web/app/assets/stylesheets/client/jamkazam.css.scss
+++ b/web/app/assets/stylesheets/client/jamkazam.css.scss
@@ -383,7 +383,7 @@ input[type="text"], input[type="password"]{
}
.error input {
- background-color:#Fadfd1 !important;
+ background-color:#fadfd1 !important;
margin-bottom:5px;
}
diff --git a/web/app/views/clients/_rsvpSubmitDialog.html.haml b/web/app/views/clients/_rsvpSubmitDialog.html.haml
index 49e7b2d9c..cbd69287d 100644
--- a/web/app/views/clients/_rsvpSubmitDialog.html.haml
+++ b/web/app/views/clients/_rsvpSubmitDialog.html.haml
@@ -10,8 +10,9 @@
%br/
%span.schedule-recurrence
%br/
- %br/
+ %br/
%span.slot-instructions Check the box(es) next to the track(s) you want to play in the session:
+ .error{:style => 'display:none'} You must select at least 1 instrument.
.rsvp-instruments
%br/
Enter a message to the other musicians in the session (optional):
diff --git a/web/spec/features/session_info_spec.rb b/web/spec/features/session_info_spec.rb
index 5de1dbb88..be3d56755 100644
--- a/web/spec/features/session_info_spec.rb
+++ b/web/spec/features/session_info_spec.rb
@@ -60,5 +60,13 @@ describe "Session Info", :js => true, :type => :feature, :capybara_feature => tr
it "should allow only RSVP approvals or session invitees to add comments" do
end
+ it "should show Submit RSVP button and launch submit dialog if user has not RSVPed" do
+ end
+
+ it "should show Cancel RSVP button and launch cancel dialog if user has RSVPed" do
+ end
+
+ it "should show no call to action button if user has not RSVPed and all slots are taken" do
+ end
end
\ No newline at end of file