diff --git a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb index df2d99a27..296f75580 100644 --- a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb +++ b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb @@ -66,6 +66,38 @@ module JamRuby end end + def teacher_no_comm_other(lesson_booking) + user = lesson_booking.teacher + @student = lesson_booking.student + @lesson_booking = lesson_booking + @suppress_user_has_account_footer = true + + sendgrid_recipients([user.email]) + sendgrid_substitute('@USERID', [user.id]) + + sendgrid_unique_args :type => "teacher_no_comm_other" + mail(:to => user.email, :subject => "JamKazam is attempting to contact " + @student.name) do |format| + format.text + format.html + end + end + + def student_no_comm_other(lesson_booking, really_late) + user = lesson_booking.student + @teacher = lesson_booking.teacher + @lesson_booking = lesson_booking + @really_late = really_late + @suppress_user_has_account_footer = true + sendgrid_recipients([user.email]) + sendgrid_substitute('@USERID', [user.id]) + + sendgrid_unique_args :type => "student_no_comm_other" + mail(:to => user.email, :subject => "JamKazam is attempting to contact " + @teacher.name) do |format| + format.text + format.html + end + end + def amazon_welcome_message(user) @user = user @subject = "Your 2 free music lessons" @@ -206,6 +238,7 @@ module JamRuby end end + def updated_email(user) @user = user diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/student_no_comm_other.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/student_no_comm_other.html.erb new file mode 100644 index 000000000..c8f73d399 --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/student_no_comm_other.html.erb @@ -0,0 +1,19 @@ +<% provide(:title, 'We are attempting to contact ' + @teacher.name) %> + + +<% if @really_late %> +

+ + + We know the teacher <%= @teacher.name %> has not responded to your last message still.

At this point, it might make sense to cancel your lesson request and try a new teacher. Click the button below to view a web page with your lesson request. You may cancel the request from that page.

+

+ <% else %> +

+ We know the teacher <%= @teacher.name %> has not responded to your last message in a while, and we are reaching out to them on your behalf.

Please sit tight!

+

+<% end %> + +VIEW LESSON REQUEST + + + diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/student_no_comm_other.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/student_no_comm_other.text.erb new file mode 100644 index 000000000..aa9292f24 --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/student_no_comm_other.text.erb @@ -0,0 +1,16 @@ +<% provide(:title, 'We are attempting to contact ' + @teacher.name) %> + +<% if @really_late %> + + We know the teacher <%= @teacher.name %> has not responded to your last message still. At this point, it might make sense to cancel your lesson request and try a new teacher. + + <% else %> + + We know the teacher <%= @teacher.name %> has not responded to your last message in a while, and we are reaching out to them on your behalf. Please sit tight! + +<% end %> + +To see this lesson request, click here: <%= @lesson_booking.web_url %> + + + diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_lesson_request.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_lesson_request.text.erb index c28cf0142..7db25cea6 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_lesson_request.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_lesson_request.text.erb @@ -1,3 +1,3 @@ <%= @sender.name %> has requested a lesson. -To see this lesson request, click here: <%= @lesson_booking.home_url %> \ No newline at end of file +To see this lesson request, click here: <%= @lesson_booking.web_url %> \ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_no_comm_other.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_no_comm_other.html.erb new file mode 100644 index 000000000..25494b0d6 --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_no_comm_other.html.erb @@ -0,0 +1,8 @@ +<% provide(:title, 'We are attempting to contact ' + @student.name) %> +

+ We know the student <%= @student.name %> has not responded to your last message in a while, and we are reaching out to them on your behalf.

Please sit tight!

+

+VIEW LESSON REQUEST + + + diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_no_comm_other.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_no_comm_other.text.erb new file mode 100644 index 000000000..7224f6c52 --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_no_comm_other.text.erb @@ -0,0 +1,8 @@ +We know the student <%= @student.name %> has not responded to your last message in a while, and we are reaching out to them on your behalf. + +Please sit tight! + +To see this lesson request, click here: <%= @lesson_booking.web_url %> + + + diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_welcome_message.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_welcome_message.text.erb index 9702e24f5..d6989f28a 100644 --- a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_welcome_message.text.erb +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/teacher_welcome_message.text.erb @@ -26,7 +26,7 @@ session, in which we will make sure your audio and video gear are working proper sure you feel comfortable with the key features you will be using in sessions with students. 3. Learn About JamClass Features -Click this link for a set of help articles specifically for teachers to learn how to respond to student lesson +Click this link for a set of help articles specifically for teachers to learn how to respond to student lesson requests, how to join your lessons when they are scheduled to begin, how to get paid, and more (https://jamkazam.desk.com/customer/en/portal/topics/926076-jamclass-online-music-lessons---for-teachers/articles). You can also use this link for a set of help articles that explain how to use the key features available to you in online sessions to effectively teach students (https://jamkazam.desk.com/customer/en/portal/topics/673198-key-features-to-use-in-online-sessions/articles). diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index f85b2ae82..baf599bd4 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -136,8 +136,7 @@ module JamRuby # notifications has_many :notifications, :class_name => "JamRuby::Notification", :foreign_key => "target_user_id" - has_many :inverse_notifications, :through => :notifications, :class_name => "JamRuby::User" - + # chats has_many :chats, :class_name => "JamRuby::ChatMessage", :foreign_key => "user_id" diff --git a/ruby/spec/mailers/render_emails_spec.rb b/ruby/spec/mailers/render_emails_spec.rb index 0ea998699..7db4da562 100644 --- a/ruby/spec/mailers/render_emails_spec.rb +++ b/ruby/spec/mailers/render_emails_spec.rb @@ -186,6 +186,30 @@ describe "RenderMailers", :slow => true do claim = FactoryGirl.create(:claimed_recording, user: user) UserMailer.lesson_attachment(user, teacher, lesson, claim).deliver_now end + + it "teacher_no_comm_other" do + @filename = "teacher_no_comm_other" + lesson = testdrive_lesson(user, teacher) + + UserMailer.deliveries.clear + UserMailer.teacher_no_comm_other(lesson.lesson_booking).deliver_now + end + + it "student_no_comm_other (late)" do + @filename = "student_no_comm_other" + lesson = testdrive_lesson(user, teacher) + + UserMailer.deliveries.clear + UserMailer.student_no_comm_other(lesson.lesson_booking, false).deliver_now + end + + it "student_no_comm_other (really late)" do + @filename = "student_no_comm_other_late" + lesson = testdrive_lesson(user, teacher) + + UserMailer.deliveries.clear + UserMailer.student_no_comm_other(lesson.lesson_booking, true).deliver_now + end end end diff --git a/ruby/spec/mailers/teacher_lesson_email_spec.rb b/ruby/spec/mailers/teacher_lesson_email_spec.rb index 9373b3eaa..480362ce1 100644 --- a/ruby/spec/mailers/teacher_lesson_email_spec.rb +++ b/ruby/spec/mailers/teacher_lesson_email_spec.rb @@ -24,6 +24,10 @@ describe "TeacherLessonEmails" do mail.to.should eql [teacher.email] end + def student_always + mail.to.should eql [user.email] + end + def school_and_teacher if @noSchool mail.to.should eql [teacher.email]