* mark user as teacher better

This commit is contained in:
Seth Call 2016-02-10 21:09:45 -06:00
parent 1652aa4bd3
commit e446c3ff44
6 changed files with 30 additions and 10 deletions

View File

@ -332,3 +332,4 @@ chat_channel.sql
jamblaster.sql
test_drive_lessons.sql
whitelist.sql
teacher_student_flags.sql

View File

@ -0,0 +1,2 @@
ALTER TABLE users ADD COLUMN is_a_student BOOLEAN NOT NULL DEFAULT FALSE;
ALTER TABLE users ADD COLUMN is_a_teacher BOOLEAN NOT NULL DEFAULT FALSE;

View File

@ -216,6 +216,8 @@ module JamRuby
validates :subscribe_email, :inclusion => {:in => [nil, true, false]}
validates :musician, :inclusion => {:in => [true, false]}
validates :show_whats_next, :inclusion => {:in => [nil, true, false]}
validates :is_a_student, :inclusion => {:in => [true, false]}
validates :is_a_teacher, :inclusion => {:in => [true, false]}
validates :mods, json: true
validates_numericality_of :last_jam_audio_latency, greater_than: MINIMUM_AUDIO_LATENCY, less_than: MAXIMUM_AUDIO_LATENCY, :allow_nil => true
validates :last_jam_updated_reason, :inclusion => {:in => [nil, JAM_REASON_REGISTRATION, JAM_REASON_NETWORK_TEST, JAM_REASON_FTUE, JAM_REASON_JOIN, JAM_REASON_IMPORT, JAM_REASON_LOGIN]}
@ -1066,6 +1068,8 @@ module JamRuby
signup_hint = options[:signup_hint]
affiliate_partner = options[:affiliate_partner]
gift_card = options[:gift_card]
student = options[:student]
teacher = options[:teacher]
user = User.new
user.validate_instruments = true
@ -1075,10 +1079,15 @@ module JamRuby
user.email = email
user.subscribe_email = true
user.terms_of_service = terms_of_service
user.musician = musician
user.reuse_card unless reuse_card.nil?
user.gifted_jamtracks = 0
user.has_redeemable_jamtrack = true
user.is_a_student = !!student
user.is_a_teacher = !!teacher
if user.is_a_student || user.is_a_teacher
musician = true
end
user.musician = !!musician
# FIXME: Setting random password for social network logins. This

View File

@ -108,15 +108,15 @@ rest = context.JK.Rest()
@setState({processing:true})
markTeacher: () ->
#rest.updateUser({teacher: true})
#.done((response) =>
# this.setState({done: true})
rest.updateUser({teacher: true})
.done((response) =>
this.setState({done: true})
context.location = '/client#/teachers/setup/introduction'
#)
#.fail((jqXHR) =>
# this.setState({processing: false})
# context.JK.app.notifyServerError(jqXHR, "Unable to Mark As Teacher")
#)
)
.fail((jqXHR) =>
this.setState({processing: false})
context.JK.app.notifyServerError(jqXHR, "Unable to Mark As Teacher")
)
createUser: () ->
$form = $('.jamtrack-signup-form')

View File

@ -87,6 +87,8 @@ ApiUsersController < ApiController
location: {:country => nil, :state => nil, :city => nil},
signup_hint: signup_hint,
gift_card: params[:gift_card],
student: params[:student],
teacher: params[:teacher],
affiliate_referral_id: cookies[:affiliate_visitor]
}
@ -169,6 +171,8 @@ ApiUsersController < ApiController
@user.update_online_presences(params[:online_presences]) if params.has_key?(:online_presences)
@user.update_performance_samples(params[:performance_samples]) if params.has_key?(:performance_samples)
@user.update_calendars(params[:calendars]) if params.has_key?(:calendars)
@user.is_a_student = params[:student] if params.has_key?(:student)
@user.is_a_teacher = params[:teacher] if params.has_key?(:teacher)
@user.save
if @user.errors.any?

View File

@ -30,6 +30,8 @@ class UserManager < BaseManager
signup_hint = options[:signup_hint]
affiliate_partner = options[:affiliate_partner]
gift_card = options[:gift_card]
student = options[:student]
teacher = options[:teacher]
recaptcha_failed = false
unless options[:skip_recaptcha] # allow callers to opt-of recaptcha
@ -74,7 +76,9 @@ class UserManager < BaseManager
any_user: any_user,
signup_hint: signup_hint,
affiliate_partner: affiliate_partner,
gift_card: gift_card)
gift_card: gift_card,
student: student,
teacher: teacher)
user
end