done
This commit is contained in:
parent
c8b49e9c36
commit
8911c8ed65
|
|
@ -8,11 +8,9 @@ ActiveAdmin.register_page "Dashboard" do
|
|||
span "JamKazam Administration Portal"
|
||||
small ul do
|
||||
li link_to "Users", admin_users_path
|
||||
li link_to "K12 Users", admin_users_path("q[import_source_equals]": "K12")
|
||||
li link_to "Teachers", admin_teachers_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
|
||||
li link_to "Upload School Users", admin_schooluseruploads_path
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,6 +30,10 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
|
|||
redirect_to :back, {notice: "Reset password to #{resetting_to }"}
|
||||
end
|
||||
|
||||
member_action :create_reset, :method => :get do
|
||||
reset_url = resource.create_tokened_reset_url
|
||||
redirect_to :back, {notice: "Reset password url created: #{reset_url}"}
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
|
@ -95,6 +99,13 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
|
|||
end
|
||||
end
|
||||
|
||||
row "Password Reset URL" do |user|
|
||||
span do
|
||||
link_to("Create Reset URL", create_reset_admin_user_path(user.id), :data => {:confirm => 'Are you sure?'})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
row :jamclass_credits
|
||||
row :via_amazon
|
||||
row "Web Profile" do
|
||||
|
|
@ -289,6 +300,7 @@ ActiveAdmin.register JamRuby::User, :as => 'Users' do
|
|||
@user.last_name = params[:jam_ruby_user][:last_name]
|
||||
@user.state = params[:jam_ruby_user][:state]
|
||||
@user.city = params[:jam_ruby_user][:city]
|
||||
@user.is_platform_instructor = params[:jam_ruby_user][:is_platform_instructor]
|
||||
@user.gifted_jamtracks = params[:jam_ruby_user][:gifted_jamtracks]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,9 @@ ActiveAdmin.register_page "SchoolUserUploads" do
|
|||
|
||||
file = params[:jam_ruby_user][:csv]
|
||||
|
||||
|
||||
created = 0
|
||||
already_existing = 0
|
||||
array_of_arrays = CSV.read(file.tempfile.path, headers:true, encoding: 'bom|utf-8')
|
||||
array_of_arrays.each do |row|
|
||||
school_name = row['School Name']
|
||||
|
|
@ -43,13 +46,25 @@ ActiveAdmin.register_page "SchoolUserUploads" do
|
|||
options[:instruments] = instruments
|
||||
user = User.signup(options)
|
||||
|
||||
if user.errors.any?
|
||||
puts "User #{user.name} #{user.email} had errors"
|
||||
puts user.errors.inspect
|
||||
already_existing = already_existing + 1
|
||||
else
|
||||
puts "User #{user.email} created"
|
||||
created = created + 1
|
||||
end
|
||||
end
|
||||
|
||||
redirect_to admin_schooluseruploads_path, :notice => "Created #{array_of_arrays.length} school students!"
|
||||
redirect_to admin_schooluseruploads_path, :notice => "Created #{created} school students. Ignored #{already_existing} because already existed."
|
||||
end
|
||||
end
|
||||
|
||||
content do
|
||||
panel "Help" do
|
||||
link_to "Download Sample CSV", asset_path("Sample_School_User_Upload.csv", target: "_blank", download: "Sample_School_User_Upload.csv")
|
||||
end
|
||||
|
||||
active_admin_form_for User.new, :url => admin_schooluseruploads_upload_schooluseruploads_path, :builder => ActiveAdmin::FormBuilder do |f|
|
||||
f.inputs "Upload School Users" do
|
||||
f.input :csv, as: :file, required: true, :label => "A school user upload"
|
||||
|
|
|
|||
|
|
@ -0,0 +1 @@
|
|||
First Name,Last Name,Email Address,User Type,School ID,School Name,License Start Date,License End Date,Source
Student,Student,seth+student1@jamkazam.com,Student,school_a,School A,1/1/20,1/1/21,K12
Student,Expired,seth+student2@jamkazam.com,Student,school_a,School A,1/2/19,1/1/20,K12
Teacher,Teacher,seth+teacher1@jamkazam.com,Student Instructor,school_a,School A,1/1/20,1/1/21,K12
Platform,Instructor,seth+platform1@jamkazam.com,Platform Instructor,school_a,School A,1/1/20,1/2/21,K12
|
||||
|
|
|
@ -26,7 +26,12 @@ module ApplicationHelper
|
|||
raise JamRuby::JamPermissionError, "date #{date} has no '-' or '/'"
|
||||
end
|
||||
|
||||
if bits[2].length == '4'
|
||||
if bits[2].length == 4 || (bits[0].length != 4 && bits[2].to_i > 12) # excel likes to do 1/1/20. So if last
|
||||
if bits[2].length == 2
|
||||
# prepend year
|
||||
|
||||
date = [bits[0], bits[1], '20' + bits[2]].join(delimiter)
|
||||
end
|
||||
Date.strptime(date, "%m#{delimiter}%d#{delimiter}%Y")
|
||||
else
|
||||
Date.strptime(date, "%Y#{delimiter}%m#{delimiter}%d")
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
= f.input :admin
|
||||
= f.input :is_onboarder, label: 'Is Support Consultant'
|
||||
= f.input :subscribe_email, label: 'Subscribed to Emails?'
|
||||
= f.input :is_platform_instructor, label: 'Is Platform Instructor?'
|
||||
= f.input :gifted_jamtracks, label: 'JamTrack Credits'
|
||||
= f.input :first_name
|
||||
= f.input :last_name
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ module JamAdmin
|
|||
# Activate observers that should always be running.
|
||||
config.active_record.observers = "JamRuby::InvitedUserObserver"
|
||||
|
||||
config.assets.paths << "#{Rails.root}/app/assets/csvs"
|
||||
config.assets.prefix = "#{ENV['RAILS_RELATIVE_URL_ROOT']}/assets"
|
||||
|
||||
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class JamRuby::User
|
||||
|
||||
attr_accessible :admin, :raw_password, :musician, :can_invite, :photo_url, :session_settings, :confirm_url, :teacher_attributes, :email_template # :invite_email
|
||||
attr_accessible :admin, :raw_password, :musician, :can_invite, :photo_url, :session_settings, :confirm_url, :teacher_attributes, :email_template, :is_platform_instructor # :invite_email
|
||||
|
||||
accepts_nested_attributes_for :teacher, allow_destroy: true
|
||||
|
||||
|
|
|
|||
|
|
@ -35,8 +35,9 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def welcome_message(user)
|
||||
def welcome_message(user, reset_url = nil)
|
||||
@user = user
|
||||
@reset_url = reset_url
|
||||
sendgrid_category "Welcome"
|
||||
sendgrid_unique_args :type => "welcome_message"
|
||||
|
||||
|
|
@ -218,6 +219,25 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
def school_welcome_message(user, reset_url)
|
||||
@user = user
|
||||
@subject= "Set a password on your new JamKazam account for your #{user.school.name} music program"
|
||||
@school = user.school
|
||||
@reset_url = reset_url
|
||||
|
||||
sendgrid_category "Welcome"
|
||||
sendgrid_unique_args :type => "welcome_message"
|
||||
|
||||
sendgrid_recipients([user.email])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
sendgrid_substitute(EmailBatchProgression::VAR_FIRST_NAME, [user.first_name])
|
||||
|
||||
mail(:to => user.email, :subject => @subject) do |format|
|
||||
format.text
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def teacher_welcome_message(user)
|
||||
@user = user
|
||||
@subject= "Welcome to JamKazam and JamClass online lessons!"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,46 @@
|
|||
<% provide(:title, @subject) %>
|
||||
|
||||
|
||||
<% if !@user.anonymous? %>
|
||||
<p>Hello <%= @vars[EmailBatch::VAR_FIRST_NAME] %> --
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
Your school <%= @school.name %> has set up a JamKazam account for you,
|
||||
so that you can participate in an online music education program through your school.
|
||||
JamKazam is an application and a platform that lets you play music with other students over the Internet, live and in sync.
|
||||
You can also use JamKazam to play and record yourself on your own.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
To use the JamKazam app, you will need to sign in to the app using an email address and a password.
|
||||
The email address is the one to which this email was sent.
|
||||
Click the button below to set a password for your JamKazam account.
|
||||
If you're worried this is a scam, please check with your school or music program instructor to verify that this is a legitimate email.
|
||||
</p>
|
||||
|
||||
<br>
|
||||
<p style="text-align:center">
|
||||
<a href="<%= @reset_url %>" style="margin:0px 8px 0px 8px;background-color: #ed3618; border: solid 1px #F27861;outline: solid 2px #ed3618;padding:3px 10px;font-size:23px;font-weight:300;cursor:pointer;color:#FC9;text-decoration:none;line-height:12px;text-align:center;">
|
||||
Set Password
|
||||
</a>
|
||||
</p>
|
||||
<br>
|
||||
|
||||
<p>
|
||||
Your instructor will help you to start using the JamKazam app in your music program with other students.
|
||||
If you already have your gear and want to set it up and start playing around with it,
|
||||
you can check out our summary setup instructions
|
||||
<a href="https://jamkazam.freshdesk.com/support/solutions/articles/66000259828" style="color:#fc0">https://jamkazam.freshdesk.com/support/solutions/articles/66000259828</a>
|
||||
and also learn about the features you can use to create, join, and play in online music sessions
|
||||
<a href="https://jamkazam.freshdesk.com/support/solutions/66000073845" style="color:#fc0">https://jamkazam.freshdesk.com/support/solutions/66000073845</a>.
|
||||
</p>
|
||||
<p>
|
||||
We hope you enjoy playing music on the JamKazam platform! If you run into trouble, please use this page to ask for help
|
||||
<a href="https://jamkazam.freshdesk.com/support/tickets/new" style="color:#fc0">https://jamkazam.freshdesk.com/support/tickets/new</a>.
|
||||
</p>
|
||||
|
||||
|
||||
<p>Best Regards,<br/>
|
||||
Team JamKazam</p>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<% if !@user.anonymous? %>
|
||||
Hello <%= @vars[EmailBatch::VAR_FIRST_NAME] %> --
|
||||
<% end %>
|
||||
|
||||
Your school <%= @school.name %> has set up a JamKazam account for you,
|
||||
so that you can participate in an online music education program through your school.
|
||||
JamKazam is an application and a platform that lets you play music with other students over the Internet, live and in sync.
|
||||
You can also use JamKazam to play and record yourself on your own.
|
||||
|
||||
To use the JamKazam app, you will need to sign in to the app using an email address and a password.
|
||||
The email address is the one to which this email was sent.
|
||||
Click the button below to set a password for your JamKazam account.
|
||||
If you're worried this is a scam, please check with your school or music program instructor to verify that this is a legitimate email.
|
||||
|
||||
Set Password: <%= @reset_url %>
|
||||
|
||||
Your instructor will help you to start using the JamKazam app in your music program with other students.
|
||||
If you already have your gear and want to set it up and start playing around with it,
|
||||
you can check out our summary setup instructions https://jamkazam.freshdesk.com/support/solutions/articles/66000259828
|
||||
and also learn about the features you can use to create, join, and play in online music sessions
|
||||
|
||||
https://jamkazam.freshdesk.com/support/solutions/66000073845.
|
||||
|
||||
We hope you enjoy playing music on the JamKazam platform! If you run into trouble, please use this page to ask for help
|
||||
https://jamkazam.freshdesk.com/support/tickets/new.
|
||||
|
||||
Best Regards,
|
||||
Team JamKazam
|
||||
|
|
@ -12,6 +12,20 @@
|
|||
your inbox so you can refer back to the links if needed.
|
||||
</p>
|
||||
|
||||
<% if @reset_url %>
|
||||
<p>
|
||||
Your account was imported for you, so you'll need to set a password.
|
||||
Click the button below to set a password for your JamKazam account.
|
||||
</p>
|
||||
<br>
|
||||
<p style="text-align:center">
|
||||
<a href="<%= @reset_url %>" style="margin:0px 8px 0px 8px;background-color: #ed3618; border: solid 1px #F27861;outline: solid 2px #ed3618;padding:3px 10px;font-size:23px;font-weight:300;cursor:pointer;color:#FC9;text-decoration:none;line-height:12px;text-align:center;">
|
||||
Set Password
|
||||
</a>
|
||||
</p>
|
||||
<br>
|
||||
<% end %>
|
||||
|
||||
<p><b style="color: white;">For Playing Music Together Live & In Sync From Different Locations</b><br/>
|
||||
JamKazam's Mac and Windows desktop apps let musicians play together live and in sync with
|
||||
high-quality audio from different locations over the Internet, with an amazing feature set for
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ module ValidationMessages
|
|||
CANT_JOIN_MULTIPLE_SESSIONS = 'You cannot join more than one music session'
|
||||
CANT_JOIN_SCHOOL_SESSION = "You can not join school sessions"
|
||||
CAN_ONLY_JOIN_SAME_SCHOOL_SESSION = "You can only join sessions from your school"
|
||||
LICENSE_EXPIRED = "Your license has expired"
|
||||
LICENSE_NOT_STARTED = "Your license has not started"
|
||||
|
||||
# chat
|
||||
CAN_ONLY_CHAT_SAME_SCHOOL = "You can only message others from your school"
|
||||
|
|
|
|||
|
|
@ -158,6 +158,13 @@ module JamRuby
|
|||
end
|
||||
end
|
||||
|
||||
if self.user.license_expired?
|
||||
errors.add(:music_session, ValidationMessages::LICENSE_EXPIRED)
|
||||
end
|
||||
|
||||
if self.user.license_not_started?
|
||||
errors.add(:music_session, ValidationMessages::LICENSE_NOT_STARTED)
|
||||
end
|
||||
|
||||
# unless user.admin?
|
||||
# num_sessions = Connection.where(:user_id => user_id)
|
||||
|
|
|
|||
|
|
@ -718,6 +718,16 @@ module JamRuby
|
|||
self.birth_date.nil? ? nil : now.year - self.birth_date.year - (self.birth_date.to_date.change(:year => now.year) > now ? 1 : 0)
|
||||
end
|
||||
|
||||
# has the user's license started? only valid if they have a license
|
||||
def license_not_started?
|
||||
license_start && Time.now < license_start
|
||||
end
|
||||
|
||||
# has the user's license ended? Only valid if they have a license
|
||||
def license_expired?
|
||||
license_end && Time.now > license_end
|
||||
end
|
||||
|
||||
def session_count
|
||||
0
|
||||
#MusicSession.where("user_id = ? AND started_at IS NOT NULL", self.id).size
|
||||
|
|
@ -957,8 +967,14 @@ module JamRuby
|
|||
if user.reset_password_token != token
|
||||
raise JamRuby::JamArgumentError.new("Invalid reset token", "token")
|
||||
end
|
||||
if Time.now - user.reset_password_token_created > 3.days
|
||||
raise JamRuby::JamArgumentError.new("Password reset has expired", "token")
|
||||
if user.import_source
|
||||
if Time.now - user.reset_password_token_created > 180.days
|
||||
raise JamRuby::JamArgumentError.new("Password reset has expired", "token")
|
||||
end
|
||||
else
|
||||
if Time.now - user.reset_password_token_created > 3.days
|
||||
raise JamRuby::JamArgumentError.new("Password reset has expired", "token")
|
||||
end
|
||||
end
|
||||
if new_password.nil? || new_password == ""
|
||||
raise JamRuby::JamArgumentError.new("Password is empty", "password")
|
||||
|
|
@ -997,6 +1013,13 @@ module JamRuby
|
|||
user
|
||||
end
|
||||
|
||||
def create_tokened_reset_url
|
||||
self.reset_password_token = SecureRandom.urlsafe_base64
|
||||
self.reset_password_token_created = Time.now
|
||||
self.save
|
||||
"#{APP_CONFIG.external_root_url}/reset_password_token?token=#{self.reset_password_token}&email=#{CGI.escape(email)}"
|
||||
end
|
||||
|
||||
def self.band_index(user_id)
|
||||
bands = Band.joins(:band_musicians)
|
||||
.where(:bands_musicians => {:user_id => "#{user_id}"})
|
||||
|
|
@ -1459,6 +1482,7 @@ module JamRuby
|
|||
user.last_name = last_name if last_name.present?
|
||||
user.email = email
|
||||
user.import_source = import_source
|
||||
user.email_confirmed = !user.import_source.nil?
|
||||
user.subscribe_email = import_source.nil?
|
||||
user.license_start = license_start
|
||||
user.license_end = license_end
|
||||
|
|
@ -1494,15 +1518,13 @@ module JamRuby
|
|||
|
||||
if school_id.present?
|
||||
if user.is_a_student
|
||||
puts "IS A STUDENT"
|
||||
user.school_id = school_id
|
||||
user.affiliate_referral = school.affiliate_partner
|
||||
elsif user.is_a_teacher
|
||||
school = School.find_by_id(school_id)
|
||||
puts "IS A TEACHER"
|
||||
user.school_id = school_id
|
||||
user.teacher = Teacher.build_teacher(user, validate_introduction: true, biography: "Empty biography", school_id: school_id)
|
||||
user.affiliate_referral = school.affiliate_partner
|
||||
puts "MADE TEACHER"
|
||||
end
|
||||
elsif retailer_id.present?
|
||||
if user.is_a_student
|
||||
|
|
@ -1636,7 +1658,6 @@ module JamRuby
|
|||
|
||||
user.save
|
||||
|
||||
puts "HOPE"
|
||||
# now that the user is saved, let's
|
||||
if invited_user && invited_user.autofriend && !invited_user.sender.nil?
|
||||
# hookup this user with the sender
|
||||
|
|
@ -1721,6 +1742,11 @@ module JamRuby
|
|||
|
||||
user.handle_test_drive_package(test_drive_package, test_drive_package_details) if test_drive_package
|
||||
|
||||
reset_url = nil
|
||||
if user.import_source
|
||||
reset_url = user.create_tokened_reset_url
|
||||
end
|
||||
|
||||
if import_source.nil? && user.is_a_student
|
||||
#if school && school.education
|
||||
# UserMailer.student_education_welcome_message(user).deliver_now
|
||||
|
|
@ -1746,9 +1772,20 @@ module JamRuby
|
|||
|
||||
|
||||
#end
|
||||
elsif user.is_a_student
|
||||
if user.import_source
|
||||
UserMailer.school_welcome_message(user, reset_url).deliver_now
|
||||
else
|
||||
UserMailer.student_welcome_message(user).deliver_now
|
||||
end
|
||||
elsif user.is_a_teacher
|
||||
puts "Email teacher"
|
||||
UserMailer.teacher_welcome_message(user).deliver_now
|
||||
if user.import_source
|
||||
UserMailer.school_welcome_message(user, reset_url).deliver_now
|
||||
else
|
||||
UserMailer.teacher_welcome_message(user).deliver_now
|
||||
end
|
||||
elsif user.is_platform_instructor
|
||||
UserMailer.welcome_message(user, reset_url).deliver_now
|
||||
elsif user.education_interest
|
||||
UserMailer.education_owner_welcome_message(user).deliver_now
|
||||
elsif user.school_interest
|
||||
|
|
@ -1756,7 +1793,6 @@ module JamRuby
|
|||
elsif user.retailer_interest
|
||||
UserMailer.retailer_owner_welcome_message(user).deliver_now
|
||||
else
|
||||
puts" generic welocem"
|
||||
UserMailer.welcome_message(user).deliver_now
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue