VRFS-1690 create RSVP request working
This commit is contained in:
parent
7f5940ac01
commit
25f325d720
|
|
@ -592,25 +592,23 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, {:user => source_user, :session => music_session})
|
||||
|
||||
if target_user.online
|
||||
msg = @@message_factory.scheduled_session_invitation(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
source_user.photo_url,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
msg = @@message_factory.scheduled_session_invitation(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
source_user.photo_url,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
else
|
||||
begin
|
||||
UserMailer.scheduled_session_invitation(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_invitation email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_invitation(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_invitation email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -630,27 +628,24 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, {:user => source_user, :session => music_session})
|
||||
|
||||
if target_user.online
|
||||
msg = @@message_factory.scheduled_session_rsvp(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
source_user.photo_url,
|
||||
notification_msg,
|
||||
source_user.id,
|
||||
instruments,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
msg = @@message_factory.scheduled_session_rsvp(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
source_user.photo_url,
|
||||
notification_msg,
|
||||
source_user.id,
|
||||
instruments.join('|'),
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
else
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rsvp email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rsvp email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -670,24 +665,21 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, {:session => music_session})
|
||||
|
||||
if target_user.online
|
||||
msg = @@message_factory.scheduled_session_rsvp_approved(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
msg = @@message_factory.scheduled_session_rsvp_approved(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
else
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp_approved(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rsvp_approved email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp_approved(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rsvp_approved email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -707,24 +699,22 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, {:session => music_session})
|
||||
|
||||
if target_user.online
|
||||
msg = @@message_factory.scheduled_session_rsvp_cancelled(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
msg = @@message_factory.scheduled_session_rsvp_cancelled(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
else
|
||||
begin
|
||||
UserMailer.send_scheduled_session_rsvp_cancelled(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send send_scheduled_session_rsvp_cancelled email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.send_scheduled_session_rsvp_cancelled(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send send_scheduled_session_rsvp_cancelled email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -744,24 +734,22 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, {:session => music_session})
|
||||
|
||||
if target_user.online
|
||||
msg = @@message_factory.scheduled_session_rsvp_cancelled_org(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
msg = @@message_factory.scheduled_session_rsvp_cancelled_org(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
else
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp_cancelled_org(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rsvp_cancelled_org email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp_cancelled_org(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rsvp_cancelled_org email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -786,24 +774,22 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, {:session => music_session})
|
||||
|
||||
if target_user.online
|
||||
msg = @@message_factory.scheduled_session_cancelled(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
msg = @@message_factory.scheduled_session_cancelled(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
else
|
||||
begin
|
||||
UserMailer.scheduled_session_cancelled(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_cancelled email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_cancelled(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_cancelled email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -827,24 +813,22 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, {:session => music_session})
|
||||
|
||||
if target_user.online
|
||||
msg = @@message_factory.scheduled_session_rescheduled(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
msg = @@message_factory.scheduled_session_rescheduled(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
else
|
||||
begin
|
||||
UserMailer.scheduled_session_rescheduled(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rescheduled email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_rescheduled(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rescheduled email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -868,24 +852,22 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, {:session => music_session})
|
||||
|
||||
if target_user.online
|
||||
msg = @@message_factory.scheduled_session_reminder(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
msg = @@message_factory.scheduled_session_reminder(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
else
|
||||
begin
|
||||
UserMailer.scheduled_session_reminder(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_reminder email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_reminder(target_user.email, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_reminder email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -909,25 +891,23 @@ module JamRuby
|
|||
|
||||
notification_msg = format_msg(notification.description, {:session => music_session})
|
||||
|
||||
if target_user.online
|
||||
msg = @@message_factory.scheduled_session_comment(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
comment,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
msg = @@message_factory.scheduled_session_comment(
|
||||
target_user.id,
|
||||
music_session.id,
|
||||
notification_msg,
|
||||
comment,
|
||||
music_session.description,
|
||||
music_session.scheduled_start,
|
||||
notification.id,
|
||||
notification.created_date
|
||||
)
|
||||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
else
|
||||
begin
|
||||
UserMailer.scheduled_session_comment(target_user.email, notification_msg, comment, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_comment email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_comment(target_user.email, notification_msg, comment, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_comment email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ module JamRuby
|
|||
end
|
||||
|
||||
def self.create(params, user)
|
||||
music_session = MusicSession.find(params[:session_id])
|
||||
music_session = MusicSession.find_by_id(params[:session_id])
|
||||
|
||||
# verify music session exists
|
||||
if music_session.nil?
|
||||
|
|
@ -46,13 +46,14 @@ module JamRuby
|
|||
raise PermissionError, "Only a session invitee can create an RSVP."
|
||||
end
|
||||
|
||||
# verify slot IDs exist in request
|
||||
if params[:rsvp_slots].blank?
|
||||
raise JamArgumentError, "You must select at least 1 slot."
|
||||
end
|
||||
|
||||
RsvpRequest.transaction do
|
||||
@rsvp = RsvpRequest.new
|
||||
|
||||
# verify slot IDs exist in request
|
||||
if params[:rsvp_slots].blank?
|
||||
raise JamRuby::JamArgumentError.new("You must select at least 1 slot.")
|
||||
end
|
||||
@rsvp.user = user
|
||||
|
||||
slot_ids = params[:rsvp_slots]
|
||||
instruments = []
|
||||
|
|
@ -77,7 +78,7 @@ module JamRuby
|
|||
raise JamRuby::JamArgumentError.new("The #{rsvp_slot.instrument_id} slot has already been approved by the session organizer.")
|
||||
else
|
||||
rsvp_request_rsvp_slot = RsvpRequestRsvpSlot.new
|
||||
rsvp_request_rsvp_slot.rsvp_request = @rsvp_request
|
||||
rsvp_request_rsvp_slot.rsvp_request = @rsvp
|
||||
rsvp_request_rsvp_slot.rsvp_slot = rsvp_slot
|
||||
rsvp_request_rsvp_slot.save
|
||||
|
||||
|
|
@ -87,6 +88,14 @@ module JamRuby
|
|||
|
||||
@rsvp.save
|
||||
|
||||
unless params[:message].blank?
|
||||
session_info_comment = SessionInfoComment.new
|
||||
session_info_comment.music_session = music_session
|
||||
session_info_comment.user = user
|
||||
session_info_comment.comment = params[:message]
|
||||
session_info_comment.save
|
||||
end
|
||||
|
||||
Notification.send_scheduled_session_rsvp(music_session, user, instruments)
|
||||
Notification.send_scheduled_session_comment(music_session, user, params[:message])
|
||||
|
||||
|
|
|
|||
|
|
@ -135,10 +135,10 @@ describe Notification do
|
|||
end
|
||||
|
||||
describe "send scheduled session invitation" do
|
||||
it "sends live notification when user is online" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification when user is offline" do
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
|
|
@ -161,10 +161,10 @@ describe Notification do
|
|||
end
|
||||
|
||||
describe "send scheduled session rsvp" do
|
||||
it "sends live notification when user is online" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification when user is offline" do
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
|
|
@ -187,10 +187,10 @@ describe Notification do
|
|||
end
|
||||
|
||||
describe "send scheduled session rsvp approved" do
|
||||
it "sends live notification when user is online" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification when user is offline" do
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
|
|
@ -213,12 +213,11 @@ describe Notification do
|
|||
end
|
||||
|
||||
describe "send scheduled session rsvp cancellation" do
|
||||
it "sends live notification when user is online" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification when user is offline" do
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
sender = FactoryGirl.create(:user)
|
||||
calls = count_publish_to_user_calls
|
||||
|
|
@ -239,10 +238,10 @@ describe Notification do
|
|||
end
|
||||
|
||||
describe "send scheduled session rsvp cancellation by organizer" do
|
||||
it "sends live notification when user is online" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification when user is offline" do
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
|
|
@ -265,10 +264,10 @@ describe Notification do
|
|||
end
|
||||
|
||||
describe "send scheduled session cancellation" do
|
||||
it "sends live notification when user is online" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification when user is offline" do
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
|
|
@ -290,10 +289,10 @@ describe Notification do
|
|||
end
|
||||
|
||||
describe "send scheduled session rescheduled" do
|
||||
it "sends live notification when user is online" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification when user is offline" do
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
|
|
@ -315,10 +314,10 @@ describe Notification do
|
|||
end
|
||||
|
||||
describe "send scheduled session reminder" do
|
||||
it "sends live notification when user is online" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification when user is offline" do
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
|
|
@ -340,10 +339,10 @@ describe Notification do
|
|||
end
|
||||
|
||||
describe "send scheduled session comment" do
|
||||
it "sends live notification when user is online" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification when user is offline" do
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ class ApiRsvpRequestsController < ApiController
|
|||
respond_with @rsvp_requests, responder: ApiResponder, :status => 200
|
||||
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
def create
|
||||
if params[:id].blank? || params[:session_id].blank?
|
||||
if params[:session_id].blank?
|
||||
render :json => {:message => "Session ID is required."}, :status => 400
|
||||
else
|
||||
@rsvp = RsvpRequest.create(params, current_user)
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "RSVP Slot API ", :type => :api do
|
||||
|
||||
include Rack::Test::Methods
|
||||
|
||||
subject { page }
|
||||
|
||||
before(:each) do
|
||||
MusicSession.delete_all
|
||||
end
|
||||
|
||||
describe "index" do
|
||||
it "should prevent request without session ID" do
|
||||
end
|
||||
|
||||
it "should allow session invitee to view all" do
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue