diff --git a/admin/Gemfile b/admin/Gemfile
index 595d94904..be68523a5 100644
--- a/admin/Gemfile
+++ b/admin/Gemfile
@@ -83,6 +83,9 @@ gem 'sendgrid_toolkit', '>= 1.1.1'
gem 'stripe'
gem 'zip-codes'
gem 'email_validator'
+gem 'best_in_place' #, github: 'bernat/best_in_place'
+
+
#group :libv8 do
# gem 'libv8', "~> 4.5.95"
diff --git a/admin/Gemfile.lock b/admin/Gemfile.lock
index d029ef2ce..a946d9be3 100644
--- a/admin/Gemfile.lock
+++ b/admin/Gemfile.lock
@@ -95,6 +95,9 @@ GEM
backports (3.11.1)
bcrypt (3.1.11)
bcrypt-ruby (3.0.1)
+ best_in_place (3.1.1)
+ actionpack (>= 3.2)
+ railties (>= 3.2)
binding_of_caller (0.8.0)
debug_inspector (>= 0.0.1)
bootstrap-sass (2.0.4.0)
@@ -628,6 +631,7 @@ DEPENDENCIES
amqp (= 0.9.8)
aws-sdk (~> 1)
bcrypt-ruby (= 3.0.1)
+ best_in_place
bootstrap-sass (= 2.0.4)
bootstrap-will_paginate (= 0.0.6)
bugsnag
diff --git a/admin/README.md b/admin/README.md
index 503c08107..badfd2200 100644
--- a/admin/README.md
+++ b/admin/README.md
@@ -11,8 +11,9 @@ Overtime we can add more administrative functions and views, but initially this
Examples of:
-Button on Show Page of Item: 'Send Client Update Notice' in jam_ruby_artifact_updates.rb
+* Button on Show Page of Item: 'Send Client Update Notice' in jam_ruby_artifact_updates.rb
+* Batch Updates in View page: onboarding.rb (CurrentlyOnboarding)
Stuff that is probably breaky:
-activeadmin_addons https://github.com/platanus/activeadmin_addons
\ No newline at end of file
+activeadmin_addons https://github.com/platanus/activeadmin_addons
diff --git a/admin/app/admin/dashboard.rb b/admin/app/admin/dashboard.rb
index 51903b216..e4c5ff6db 100644
--- a/admin/app/admin/dashboard.rb
+++ b/admin/app/admin/dashboard.rb
@@ -9,7 +9,8 @@ ActiveAdmin.register_page "Dashboard" do
small ul do
li link_to "Users", admin_users_path
li link_to "Teachers", admin_teachers_path
- li link_to "Onboarding Management", admin_currently_onboardings_path
+ li link_to "Onboarding Management", admin_onboarder_managements_path
+ li link_to "Onboarding Settings", admin_onboarders_path
li link_to "Lesson Sessions", admin_lesson_sessions_path
li link_to "Slow Lesson Responses", admin_slow_responses_path
diff --git a/admin/app/admin/jam_ruby_users.rb b/admin/app/admin/jam_ruby_users.rb
index cce181faf..60f1dda4f 100644
--- a/admin/app/admin/jam_ruby_users.rb
+++ b/admin/app/admin/jam_ruby_users.rb
@@ -16,6 +16,13 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
form :partial => "form"
+ member_action :delete_forever, :method => :get do
+ resource.permanently_delete
+ redirect_to :back, {notice: 'User email and login credentials have been permanently changed'}
+ end
+
+
+
show do |user|
panel "Common" do
attributes_table do
@@ -60,6 +67,11 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
end
end
end
+ row "Delete Forever" do |user|
+ span do
+ link_to("delete forever", delete_forever_admin_user_path(user.id), :data => {:confirm => 'Are you sure?'})
+ end
+ end
row :jamclass_credits
row :via_amazon
@@ -243,11 +255,13 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
@user.email = params[:jam_ruby_user][:email]
@user.admin = params[:jam_ruby_user][:admin]
@user.is_onboarder = params[:jam_ruby_user][:is_onboarder]
+ @user.subscribe_email = params[:jam_ruby_user][:subscribe_email]
@user.musician = params[:jam_ruby_user][:musician]
@user.first_name = params[:jam_ruby_user][:first_name]
@user.last_name = params[:jam_ruby_user][:last_name]
@user.state = params[:jam_ruby_user][:state]
@user.city = params[:jam_ruby_user][:city]
+ @user.gifted_jamtracks = params[:jam_ruby_user][:gifted_jamtracks]
if params[:jam_ruby_user][:show_frame_options].to_i == 1
diff --git a/admin/app/admin/onboarders.rb b/admin/app/admin/onboarders.rb
new file mode 100644
index 000000000..bb84642bb
--- /dev/null
+++ b/admin/app/admin/onboarders.rb
@@ -0,0 +1,91 @@
+ActiveAdmin.register JamRuby::User, :as => 'Onboarder' do
+
+ menu :label => 'Onboarder Settings', :parent => 'JamClass'
+
+ config.sort_order = 'created_at'
+ config.batch_actions = true
+ config.per_page = 100
+ config.paginate = true
+ config.filters = false
+ config.clear_action_items!
+ batch_action :destroy, false
+
+ scope("All Onboarders", default: true) { |scope| scope.where(is_onboarder: true).order(:created_at) }
+
+ controller do
+ active_admin_config.includes.push :onboarding_users
+
+ def update
+ resource.max_onboardings = params[:jam_ruby_user][:max_onboardings]
+ resource.save!
+ success.json {}
+ end
+ end
+
+
+
+ index do
+ def last_week
+ @last_week_result ||= calculate_last_week
+ end
+
+ def calculate_last_week
+ start_day = Date.today.beginning_of_week(:sunday).yesterday.beginning_of_week(:sunday)
+ end_day = start_day.end_of_week(:sunday)
+ result = [start_day, end_day]
+ result
+ end
+
+ def this_week
+ @this_week_result ||= calculate_this_week
+ end
+
+ def calculate_this_week
+ start_day = Date.today.beginning_of_week(:sunday)
+ end_day = start_day.end_of_week(:sunday)
+ result = [start_day, end_day]
+ result
+ end
+
+ def week_display(week)
+ start_day = week[0]
+ end_day = week[1]
+ mmyy = start_day.strftime('%b')
+ "#{mmyy} #{start_day.day}-#{end_day.day}"
+ end
+
+ def onboarding_select
+ array = []
+ 100.times do |i|
+ array.push [i.to_s, i.to_s]
+ end
+ array
+ end
+ column "Name" do |user|
+ div do
+ div do
+ link_to user.name, user.admin_url
+ end
+ div do
+ user.email
+ end
+ end
+ end
+ column "Max Onboardings" do |user|
+ best_in_place user, :max_onboardings, as: :select, url: admin_onboarder_path(user),:collection => onboarding_select
+ end
+ column "Current Week #{week_display(this_week)}" do |user|
+ start_date, last_date = this_week
+ user.onboarding_users.where(onboarder_assigned_at: start_date..last_date).count
+ end
+ column "Previous Week #{week_display(last_week)}" do |user|
+ start_date, last_date = last_week
+ user.onboarding_users.where(onboarder_assigned_at: start_date..last_date).count
+ end
+ column "Current Student WIP" do |user|
+ user.onboarding_users.where('onboarding_status = ? OR onboarding_status = ?', User::ONBOARDING_STATUS_ASSIGNED, User::ONBOARDING_STATUS_EMAILED).count
+ end
+ end
+
+
+end
\ No newline at end of file
diff --git a/admin/app/admin/onboarding.rb b/admin/app/admin/onboarding.rb
index 0adaf3285..8e4358691 100644
--- a/admin/app/admin/onboarding.rb
+++ b/admin/app/admin/onboarding.rb
@@ -1,6 +1,6 @@
-ActiveAdmin.register JamRuby::User, :as => 'CurrentlyOnboarding' do
+ActiveAdmin.register JamRuby::User, :as => 'OnboarderManagement' do
- menu :label => 'Currently Onboarding', :parent => 'JamClass'
+ menu :label => 'Onboarder Management', :parent => 'JamClass'
config.sort_order = 'created_at desc'
config.batch_actions = true
@@ -11,7 +11,7 @@ ActiveAdmin.register JamRuby::User, :as => 'CurrentlyOnboarding' do
batch_action :destroy, false
batch_action :onboarder, form: -> { {
- support_consultant: (User.where(is_onboarder: true).includes(:onboarding_users).map {|user| ["#{user.name} (#{user.onboarding_users.length})", user.id]}).to_a.unshift(['Unassign', ''])
+ support_consultant: (User.where(is_onboarder: true).includes(:onboarding_users).map {|user| ["#{user.name} (#{user.onboarding_users.where('onboarding_status = ? OR onboarding_status = ?', User::ONBOARDING_STATUS_ASSIGNED, User::ONBOARDING_STATUS_EMAILED).count})", user.id]}).to_a.unshift(['Unassign', ''])
} } do |ids, inputs|
onboarder = inputs[:support_consultant]
if onboarder.blank?
@@ -41,7 +41,11 @@ ActiveAdmin.register JamRuby::User, :as => 'CurrentlyOnboarding' do
filter :onboarder, as: :select, :collection => User.where(is_onboarder: true), label: 'Support Consultant'
filter :onboarder_id_blank, :as => :boolean, label: 'Unassigned'
filter :onboarding_escalation_reason_present, :as => :boolean, label: 'Escalated'
- scope("TestDrive/Amazon Users", default: true) { |scope| scope.joins(:posa_cards).where('posa_cards.lesson_package_type_id in (?)', LessonPackageType::AMAZON_PACKAGES + LessonPackageType::LESSON_PACKAGE_TYPES) }
+ scope("Unassigned", default: true) { |scope| scope.joins(:posa_cards).where(onboarding_status: User::ONBOARDING_STATUS_UNASSIGNED).where('posa_cards.lesson_package_type_id in (?)', LessonPackageType::AMAZON_PACKAGES + LessonPackageType::LESSON_PACKAGE_TYPES) }
+ scope("Escalated") { |scope| scope.joins(:posa_cards).where('onboarding_status = ?', User::ONBOARDING_STATUS_ESCALATED).where('posa_cards.lesson_package_type_id in (?)', LessonPackageType::AMAZON_PACKAGES + LessonPackageType::LESSON_PACKAGE_TYPES) }
+ scope("Needs Manual Email") { |scope| scope.joins(:posa_cards).where(onboarding_status: User::ONBOARDING_STATUS_ONBOARDED).where('(stuck_take_flesson = TRUE AND sent_admin_take_flesson_email_at is NULL) OR (stuck_take_2nd_flesson = TRUE AND sent_admin_take_2nd_flesson_email_at IS NULL) OR (stuck_take_plesson = TRUE AND sent_admin_take_plesson_email_at IS NULL)').where('posa_cards.lesson_package_type_id in (?)', LessonPackageType::AMAZON_PACKAGES + LessonPackageType::LESSON_PACKAGE_TYPES) }
+ scope("Assigned") { |scope| scope.joins(:posa_cards).where('onboarding_status = ? OR onboarding_status = ?', User::ONBOARDING_STATUS_ASSIGNED, User::ONBOARDING_STATUS_EMAILED).where('posa_cards.lesson_package_type_id in (?)', LessonPackageType::AMAZON_PACKAGES + LessonPackageType::LESSON_PACKAGE_TYPES) }
+ scope("All TestDrive/Amazon Users") { |scope| scope.joins(:posa_cards).where('posa_cards.lesson_package_type_id in (?)', LessonPackageType::AMAZON_PACKAGES + LessonPackageType::LESSON_PACKAGE_TYPES) }
controller do
@@ -59,10 +63,23 @@ ActiveAdmin.register JamRuby::User, :as => 'CurrentlyOnboarding' do
column "Escalated Reason", :onboarding_escalation_reason
column "Support Consultant" do |user|
if user.onboarder
- link_to "#{user.onboarder.name} (#{user.onboarder.onboarding_users.count})", user.onboarder.admin_url
+ link_to "#{user.onboarder.name} (#{user.onboarder.onboarding_users.where('onboarding_status = ? OR onboarding_status = ?', User::ONBOARDING_STATUS_ASSIGNED, User::ONBOARDING_STATUS_EMAILED).count})", user.onboarder.admin_url
else
end
end
+ column "Manual Email Needed" do |user|
+
+ div do
+ if user.stuck_take_plesson
+ link_to("sent take paid lesson email", mark_sent_paid_lesson_admin_onboarder_management_path(user.id), {'data-confirm': "You sent an email manually to the user to remind them to take a paid lesson?"})
+ elsif user.stuck_take_2nd_flesson
+ link_to("sent take 2nd lesson email", mark_sent_2nd_free_lesson_admin_onboarder_management_path(user.id), {'data-confirm': "You sent an email manually to the user to remind them to take 2nd free lesson?"})
+ elsif user.stuck_take_flesson
+ link_to("sent take 1st lesson email", mark_sent_1st_free_lesson_admin_onboarder_management_path(user.id), {'data-confirm': "You sent an email manually to the user to remind them to take a 1st free lesson?"})
+ else
+ end
+ end
+ end
column "Signup" do |user|
user.created_at.to_date
@@ -74,6 +91,17 @@ ActiveAdmin.register JamRuby::User, :as => 'CurrentlyOnboarding' do
column "Email 4", :onboarding_email_4_sent_at
column "Email 5", :onboarding_email_5_sent_at
column "Test Session", :onboarding_test_session_scheduled_at
+ column "Admin Actions" do |user|
+ div do
+ if user.is_waiting_onboarding || user.is_onboarding
+ link_to("mark onboarded", mark_onboarded_admin_onboarder_management_path(user.id), { 'data-confirm': "Mark onboarded?"})
+ end
+ if user.is_waiting_onboarding || user.is_onboarding
+ link_to("mark lost", mark_lost_admin_onboarder_management_path(user.id), { 'data-confirm': "Mark lost (reason = Other)?"})
+ end
+ end
+ end
+ column "Onboarder Notes", :onboarding_onboarder_notes
end
member_action :update_onboarder, :method => :post do
@@ -82,4 +110,29 @@ ActiveAdmin.register JamRuby::User, :as => 'CurrentlyOnboarding' do
redirect_to :back
end
+ member_action :mark_sent_paid_lesson, :method => :get do
+ resource.mark_sent_paid_lesson
+ redirect_to :back
+ end
+
+ member_action :mark_sent_2nd_free_lesson, :method => :get do
+ resource.mark_sent_2nd_free_lesson
+ redirect_to :back
+ end
+
+ member_action :mark_sent_1st_free_lesson, :method => :get do
+ resource.mark_sent_1st_free_lesson
+ redirect_to :back
+ end
+
+ member_action :mark_onboarded, :method => :get do
+ resource.mark_onboarded
+ redirect_to :back
+ end
+
+ member_action :mark_lost, :method => :get do
+ resource.mark_lost
+ redirect_to :back
+ end
+
end
\ No newline at end of file
diff --git a/admin/app/assets/javascripts/active_admin.js b/admin/app/assets/javascripts/active_admin.js
index 84a187b5a..df9db3400 100644
--- a/admin/app/assets/javascripts/active_admin.js
+++ b/admin/app/assets/javascripts/active_admin.js
@@ -12,3 +12,8 @@
// //= require autocomplete-rails
//= require base
//= require_tree .
+
+
+$(document).ready(function() {
+ jQuery(".best_in_place").best_in_place()
+})
diff --git a/admin/app/assets/javascripts/active_admin.js.coffee b/admin/app/assets/javascripts/active_admin.js.coffee
index e211bdfe7..7d9d7acbd 100644
--- a/admin/app/assets/javascripts/active_admin.js.coffee
+++ b/admin/app/assets/javascripts/active_admin.js.coffee
@@ -1,2 +1,10 @@
#= require active_admin/base
#= require jquery3
+#= require best_in_place
+#= require jquery.purr
+#= require best_in_place.purr
+
+$(document).ready ->
+ # IS NOT HAPPENING: USE ACTIVE_ADMIN.JS
+ console.log("DAT COFFEE INIT")
+ jQuery(".best_in_place").best_in_place()
\ No newline at end of file
diff --git a/admin/app/helpers/application_helper.rb b/admin/app/helpers/application_helper.rb
index 80731359d..6e9385e59 100644
--- a/admin/app/helpers/application_helper.rb
+++ b/admin/app/helpers/application_helper.rb
@@ -1,5 +1,4 @@
module ApplicationHelper
-
end
diff --git a/admin/app/helpers/jam_sessions_helper.rb b/admin/app/helpers/jam_sessions_helper.rb
index bf244b019..9ef3f0789 100644
--- a/admin/app/helpers/jam_sessions_helper.rb
+++ b/admin/app/helpers/jam_sessions_helper.rb
@@ -1,2 +1,3 @@
module JamSessionsHelper
+
end
\ No newline at end of file
diff --git a/admin/app/views/admin/users/_form.html.slim b/admin/app/views/admin/users/_form.html.slim
index 2e8d483b9..df29c3115 100644
--- a/admin/app/views/admin/users/_form.html.slim
+++ b/admin/app/views/admin/users/_form.html.slim
@@ -3,6 +3,8 @@
= f.input :email, label: 'Email'
= f.input :admin
= f.input :is_onboarder, label: 'Is Support Consultant'
+ = f.input :subscribe_email, label: 'Subscribed to Emails?'
+ = f.input :gifted_jamtracks, label: 'JamTrack Credits'
= f.input :first_name
= f.input :last_name
= f.input :city
diff --git a/db/manifest b/db/manifest
index 19a9059d2..b8a025a75 100755
--- a/db/manifest
+++ b/db/manifest
@@ -383,4 +383,8 @@ age_out_sessions.sql
alter_crash_dumps.sql
onboarding.sql
better_lesson_notices.sql
-teacher_search_control.sql
\ No newline at end of file
+teacher_search_control.sql
+user_timezone.sql
+onboarder_limit.sql
+onboarding_emails.sql
+limit_counter_reminders.sql
\ No newline at end of file
diff --git a/db/up/limit_counter_reminders.sql b/db/up/limit_counter_reminders.sql
new file mode 100644
index 000000000..08d57e0a8
--- /dev/null
+++ b/db/up/limit_counter_reminders.sql
@@ -0,0 +1 @@
+ALTER TABLE lesson_sessions ADD COLUMN counter_reminders INTEGER NOT NULL DEFAULT 0;
\ No newline at end of file
diff --git a/db/up/onboarder_limit.sql b/db/up/onboarder_limit.sql
new file mode 100644
index 000000000..2a2e35ba9
--- /dev/null
+++ b/db/up/onboarder_limit.sql
@@ -0,0 +1 @@
+ALTER TABLE users ADD COLUMN max_onboardings INTEGER NOT NULL DEFAULT 0;
diff --git a/db/up/onboarding_emails.sql b/db/up/onboarding_emails.sql
new file mode 100644
index 000000000..4e4d3113e
--- /dev/null
+++ b/db/up/onboarding_emails.sql
@@ -0,0 +1,28 @@
+ALTER TABLE users ADD COLUMN sent_take_flesson_email_at TIMESTAMP WITHOUT TIME ZONE;
+ALTER TABLE users ADD COLUMN sent_take_flesson_email_times INTEGER NOT NULL DEFAULT 0;
+ALTER TABLE users ADD COLUMN sent_take_2nd_flesson_email_at TIMESTAMP WITHOUT TIME ZONE;
+ALTER TABLE users ADD COLUMN sent_take_2nd_flesson_email_times INTEGER NOT NULL DEFAULT 0;
+ALTER TABLE users ADD COLUMN sent_take_plesson_email_at TIMESTAMP WITHOUT TIME ZONE;
+ALTER TABLE users ADD COLUMN sent_take_plesson_email_times INTEGER NOT NULL DEFAULT 0;
+ALTER TABLE users ADD COLUMN second_onboarding_free_lesson_at timestamp without time zone;
+ALTER TABLE users ADD COLUMN sent_admin_take_flesson_email_at TIMESTAMP WITHOUT TIME ZONE;
+ALTER TABLE users ADD COLUMN sent_admin_take_2nd_flesson_email_at TIMESTAMP WITHOUT TIME ZONE;
+ALTER TABLE users ADD COLUMN sent_admin_take_plesson_email_at TIMESTAMP WITHOUT TIME ZONE;
+ALTER TABLE users ADD COLUMN stuck_take_flesson BOOLEAN NOT NULL DEFAULT FALSE;
+ALTER TABLE users ADD COLUMN stuck_take_2nd_flesson BOOLEAN NOT NULL DEFAULT FALSE;
+ALTER TABLE users ADD COLUMN stuck_take_plesson BOOLEAN NOT NULL DEFAULT FALSE;
+ALTER TABLE teachers ADD COLUMN random_order INTEGER NOT NULL DEFAULT 0;
+ALTER TABLE users ADD COLUMN send_onboarding_survey BOOLEAN NOT NULL DEFAULT FALSE;
+ALTER TABLE users ADD COLUMN sent_onboarding_survey_at TIMESTAMP WITHOUT TIME ZONE;
+CREATE INDEX index_first_onboarding_paid_lesson_at ON users USING btree(first_onboarding_paid_lesson_at);
+CREATE INDEX index_onboarding_onboarded_at ON users USING btree(onboarding_onboarded_at);
+CREATE INDEX index_onboarding_status ON users USING btree(onboarding_status);
+CREATE INDEX index_stuck_take_plesson ON users USING btree(stuck_take_plesson);
+CREATE INDEX index_stuck_take_2nd_flesson ON users USING btree(stuck_take_2nd_flesson);
+CREATE INDEX index_stuck_take_flesson ON users USING btree(stuck_take_flesson);
+CREATE INDEX index_sent_admin_take_flesson_email_at ON users USING btree(sent_admin_take_flesson_email_at);
+CREATE INDEX index_sent_admin_take_2nd_flesson_email_at ON users USING btree(sent_admin_take_2nd_flesson_email_at);
+CREATE INDEX index_sent_admin_take_plesson_email_at ON users USING btree(sent_admin_take_plesson_email_at);
+CREATE INDEX index_posa_cards_lesson_package_type_id ON posa_cards USING btree(lesson_package_type_id);
+
+UPDATE teachers set random_order = sub.row_number * random() * 1000 from (select id, row_number() over () from teachers) as sub ;
\ No newline at end of file
diff --git a/db/up/user_timezone.sql b/db/up/user_timezone.sql
new file mode 100644
index 000000000..7f0e0da1d
--- /dev/null
+++ b/db/up/user_timezone.sql
@@ -0,0 +1,2 @@
+ALTER TABLE users ADD COLUMN timezone VARCHAR;
+ALTER TABLE users ADD COLUMN deleted BOOLEAN NOT NULL DEFAULT FALSE;
\ No newline at end of file
diff --git a/ruby/lib/jam_ruby/app/mailers/admin_mailer.rb b/ruby/lib/jam_ruby/app/mailers/admin_mailer.rb
index 79f5c2c0f..4d6a50682 100644
--- a/ruby/lib/jam_ruby/app/mailers/admin_mailer.rb
+++ b/ruby/lib/jam_ruby/app/mailers/admin_mailer.rb
@@ -52,6 +52,15 @@ module JamRuby
subject: options[:subject])
end
+ def ugly(options)
+ mail(to: options[:to],
+ cc: options[:cc],
+ from: APP_CONFIG.email_generic_from,
+ body: options[:body],
+ content_type: "text/plain",
+ subject: options[:subject])
+ end
+
def recurly_alerts(user, options)
body = options[:body]
diff --git a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb
index 296f75580..9cece2313 100644
--- a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb
+++ b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb
@@ -49,6 +49,92 @@ module JamRuby
end
end
+ def take_paid_lesson(user)
+ @user = user
+ @lesson = user.taken_lessons.order(:created_at).last
+ @teacher = @lesson.teacher
+
+ if user.sent_take_plesson_email_times == 0
+ @subject = "Book your next lesson with your instructor now!"
+ elsif user.sent_take_plesson_email_times == 1
+ @subject = "Book your next lesson to continue your musical journey"
+ else
+ @subject = "The best way to improve on your instrument is with a great instructor - book today!"
+ end
+ sendgrid_category "promo_lesson_reminder"
+ sendgrid_unique_args :type => "promo_lesson_reminder"
+
+ sendgrid_recipients([user.email])
+ sendgrid_substitute('@USERID', [user.id])
+
+ mail(:to => user.email, :subject => @subject) do |format|
+ format.text
+ format.html
+ end
+ end
+
+ def take_second_free_lesson(user)
+ @user = user
+ @lesson = user.taken_lessons.order(:created_at).last
+ @teacher = @lesson.teacher
+
+ if user.sent_take_2nd_flesson_email_times == 0
+ @subject = "Book your second free lesson now!"
+ elsif user.sent_take_2nd_flesson_email_times == 1
+ @subject = "Book your second free lesson to continue your musical journey"
+ else
+ @subject = "Last reminder to book your next free lesson"
+ end
+
+ sendgrid_category "promo_lesson_reminder"
+ sendgrid_unique_args :type => "promo_lesson_reminder"
+
+ sendgrid_recipients([user.email])
+ sendgrid_substitute('@USERID', [user.id])
+
+ mail(:to => user.email, :subject => @subject) do |format|
+ format.text
+ format.html
+ end
+ end
+
+ def take_first_free_lesson(user)
+ @user = user
+ if user.sent_take_flesson_email_times == 0
+ @subject = "Book your first free lesson now!"
+ elsif user.sent_take_flesson_email_times == 1
+ @subject = "Book your first free lesson to start your musical journey"
+ else
+ @subject = "Last reminder to book your free lessons - $60 value!"
+ end
+
+ sendgrid_category "promo_lesson_reminder"
+ sendgrid_unique_args :type => "promo_lesson_reminder"
+
+ sendgrid_recipients([user.email])
+ sendgrid_substitute('@USERID', [user.id])
+
+ mail(:to => user.email, :subject => @subject) do |format|
+ format.text
+ format.html
+ end
+ end
+
+ def onboarding_survey(user)
+ @user = user
+ @subject = "1-minute JamKazam survey - please help us give good support!"
+ sendgrid_category "onboarding_survey"
+ sendgrid_unique_args :type => "onboarding_survey"
+
+ sendgrid_recipients([user.email])
+ sendgrid_substitute('@USERID', [user.id])
+
+ mail(:to => user.email, :subject => @subject) do |format|
+ format.text
+ format.html
+ end
+ end
+
def student_education_welcome_message(user)
@user = user
@subject = "Welcome to JamKazam and JamClass online lessons!"
diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/onboarding_survey.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/onboarding_survey.html.erb
new file mode 100644
index 000000000..f552b2d7b
--- /dev/null
+++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/onboarding_survey.html.erb
@@ -0,0 +1,12 @@
+
+<% if !@user.anonymous? %>
+
Hi <%= @user.first_name %>,
+
+<% end %>
+
+
+ Please click this link to take a literally 1-minute survey on your onboarding experience: https://www.surveymonkey.com/r/93JC2KJ. This will help us deliver better support to other students like you. Thank you!
+
+
+
Best Regards,
+ Team JamKazam
\ No newline at end of file
diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/onboarding_survey.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/onboarding_survey.text.erb
new file mode 100644
index 000000000..91abd4b12
--- /dev/null
+++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/onboarding_survey.text.erb
@@ -0,0 +1,9 @@
+<% if !@user.anonymous? %>
+Hi <%= @user.first_name %>,
+<% end %>
+
+Please click this link to take a literally 1-minute survey on your onboarding experience: https://www.surveymonkey.com/r/93JC2KJ. This will help us deliver better support to other students like you. Thank you!
+
+
+Best Regards,
+Team JamKazam
diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_first_free_lesson.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_first_free_lesson.html.erb
new file mode 100644
index 000000000..b3055afbf
--- /dev/null
+++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_first_free_lesson.html.erb
@@ -0,0 +1,45 @@
+<% provide(:title, @subject) %>
+
+
+<% if !@user.anonymous? %>
+
Hi <%= @user.first_name %>,
+
+<% end %>
+
+<% if @user.sent_take_flesson_email_times == 0 %>
+
+
We hope you had a great support experience with the JamKazam consultant who prepared you to get into your first free online lesson. Life gets busy. So before you forget about it, please find an instructor who looks great for you, and book your first free lesson now!
+
+
+
+ Here is an article that explains how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your first lesson: http://bit.ly/2k3qNMT.
+
We noticed you haven't booked your first free lesson yet. Don't forget to take advantage of this amazing limited promotion. Your two free lessons are valued at approximately $60! Book your first lesson today.
+
+ Here is an article that explains how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your first lesson: http://bit.ly/2k3qNMT.
+
It looks like you're busy, but we wanted to remind you once more to book your first free lesson before you forget and let this terrific promotion get away. Start your musical journey with a world-class instructor who can help you achieve your goals. There is no better way to learn and master your new instrument!
+
+ Here is an article that explains how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your first lesson: http://bit.ly/2k3qNMT.
+
\ No newline at end of file
diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_first_free_lesson.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_first_free_lesson.text.erb
new file mode 100644
index 000000000..869994f72
--- /dev/null
+++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_first_free_lesson.text.erb
@@ -0,0 +1,26 @@
+<% if !@user.anonymous? %>
+Hi <%= @user.first_name %>,
+<% end %>
+
+<% if @user.sent_take_flesson_email_times == 0 %>
+We hope you had a great support experience with the JamKazam consultant who prepared you to get into your first free online lesson. Life gets busy. So before you forget about it, please find an instructor who looks great for you, and book your first free lesson now!
+
+Here is an article that explains how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your first lesson:http://bit.ly/2k3qNMT.
+
+If you have any trouble, please email us at support@jamkazam.com. Or you can call us at 877-376-8742.
+<% elsif @user.sent_take_flesson_email_times == 1 %>
+We noticed you haven't booked your first free lesson yet. Don't forget to take advantage of this amazing limited promotion. Your two free lessons are valued at approximately $60! Book your first lesson today.
+
+Here is an article that explains how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your first lesson:http://bit.ly/2k3qNMT.
+
+If you have any trouble, please email us at support@jamkazam.com. Or you can call us at 877-376-8742.
+<% else %>
+It looks like you're busy, but we wanted to remind you once more to book your first free lesson before you forget and let this terrific promotion get away. Start your musical journey with a world-class instructor who can help you achieve your goals. There is no better way to learn and master your new instrument!
+
+Here is an article that explains how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your first lesson:http://bit.ly/2k3qNMT.
+
+If you have any trouble, please email us at support@jamkazam.com. Or you can call us at 877-376-8742.
+<% end %>
+
+Best Regards,
+Team JamKazam
\ No newline at end of file
diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_paid_lesson.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_paid_lesson.html.erb
new file mode 100644
index 000000000..0979d40fc
--- /dev/null
+++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_paid_lesson.html.erb
@@ -0,0 +1,45 @@
+<% provide(:title, @subject) %>
+
+
+<% if !@user.anonymous? %>
+
Hi <%= @user.first_name %>,
+
+<% end %>
+
+<% if @user.sent_take_plesson_email_times == 0 %>
+
+ Now that you've enjoyed your first two lessons free, continue down the musical path you've started with your instructor. Schedule recurring weekly lessons for the best results and fastest progress, or schedule lessons one at a time. It's up to you.
+
+
+ You can book your regular weekly or one-at-a-time lessons with your instructor at his/her profile page here: <%= @teacher.teacher_profile_url %>.
+
+ The best way - by far - to master your instrument and reach your musical goals is to have a great instructor - someone who can guide you, build the right foundation and technique from the beginning, inspire you, and make your practice pay off with the greatest return on your investment of time. If you want to play well, stay on the path with your instructor.
+
+
+ You can book your regular weekly or one-at-a-time lessons with your instructor at his/her profile page here: <%= @teacher.teacher_profile_url %>.
+
+
+ Or if you need to find a different instructor for any reason, here's an article on how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your lesson: http://bit.ly/2k3qNMT.
+
\ No newline at end of file
diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_paid_lesson.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_paid_lesson.text.erb
new file mode 100644
index 000000000..935699c18
--- /dev/null
+++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_paid_lesson.text.erb
@@ -0,0 +1,28 @@
+<% if !@user.anonymous? %>
+Hi <%= @user.first_name %>,
+<% end %>
+
+<% if @user.sent_take_plesson_email_times == 0 %>
+Now that you've enjoyed your first two lessons free, continue down the musical path you've started with your instructor. Schedule recurring weekly lessons for the best results and fastest progress, or schedule lessons one at a time. It's up to you.
+
+You can book your regular weekly or one-at-a-time lessons with your instructor at his/her profile page here: <%= @teacher.teacher_profile_url %>.
+
+If you have any trouble, please email us at support@jamkazam.com. Or you can call us at 877-376-8742.
+<% elsif @user.sent_take_plesson_email_times == 1 %>
+You're off to a great start with your music teacher. Don't lose momentum!
+
+You can book your regular weekly or one-at-a-time lessons with your instructor at his/her profile page here: <%= @teacher.teacher_profile_url %>.
+
+If you have any trouble, please email us at support@jamkazam.com. Or you can call us at 877-376-8742.
+<% else %>
+The best way - by far - to master your instrument and reach your musical goals is to have a great instructor - someone who can guide you, build the right foundation and technique from the beginning, inspire you, and make your practice pay off with the greatest return on your investment of time. If you want to play well, stay on the path with your instructor.
+
+You can book your regular weekly or one-at-a-time lessons with your instructor at his/her profile page here: <%= @teacher.teacher_profile_url %>.
+
+Or if you need to find a different instructor for any reason, here's an article on how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your lesson: http://bit.ly/2k3qNMT.
+
+If you have any trouble, please email us at support@jamkazam.com. Or you can call us at 877-376-8742.
+<% end %>
+
+Best Regards,
+Team JamKazam
diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_second_free_lesson.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_second_free_lesson.html.erb
new file mode 100644
index 000000000..bca989c40
--- /dev/null
+++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/take_second_free_lesson.html.erb
@@ -0,0 +1,29 @@
+<% provide(:title, @subject) %>
+
+
+<% if !@user.anonymous? %>
+
Hi <%= @user.first_name %>,
+
+<% end %>
+
+<% if @user.sent_take_2nd_flesson_email_times == 0 %>
+
We hope you had a great first music lesson with <%= @teacher.name %>. Schedule your second free lesson with this instructor now at this page: <%= @teacher.teacher_profile_url %>, and continue your musical journey!
Just a quick reminder to take advantage of your second free lesson, and book it today! Schedule your second lesson with the same instructor from your first lesson at this page: <%= @teacher.teacher_profile_url %>.
+
Or if you didn't love your instructor for any reason, you can search for a different instructor for your second free lesson. Here's the article on how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your lesson: http://bit.ly/2k3qNMT.
We're sending you one last reminder to book your second free lesson. Don't put it off to later and forget! A great instructor will make a huge difference in the progress you make in mastering your new instrument. You can book another lesson with your first instructor at his/her profile page here: <%= @teacher.teacher_profile_url %>.
+
Or if you didn't love your instructor for any reason, you can search for a different instructor for your second free lesson. Here's the article on how to search for your ideal teacher: http://bit.ly/2kBPXBz. And here is an article that explains how to book your lesson: http://bit.ly/2k3qNMT.