diff --git a/db/manifest b/db/manifest index f67ef865e..55ae4eae6 100755 --- a/db/manifest +++ b/db/manifest @@ -332,3 +332,4 @@ chat_channel.sql jamblaster.sql test_drive_lessons.sql whitelist.sql +teacher_student_flags.sql \ No newline at end of file diff --git a/db/up/teacher_student_flags.sql b/db/up/teacher_student_flags.sql new file mode 100644 index 000000000..c94290d2f --- /dev/null +++ b/db/up/teacher_student_flags.sql @@ -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; \ No newline at end of file diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 45437306d..43fabf0b3 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -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 diff --git a/web/app/assets/javascripts/react-components/landing/JamClassTeacherLandingPage.js.jsx.coffee b/web/app/assets/javascripts/react-components/landing/JamClassTeacherLandingPage.js.jsx.coffee index 4116e7101..97c3692dd 100644 --- a/web/app/assets/javascripts/react-components/landing/JamClassTeacherLandingPage.js.jsx.coffee +++ b/web/app/assets/javascripts/react-components/landing/JamClassTeacherLandingPage.js.jsx.coffee @@ -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') diff --git a/web/app/controllers/api_users_controller.rb b/web/app/controllers/api_users_controller.rb index e4a398950..3413c9335 100644 --- a/web/app/controllers/api_users_controller.rb +++ b/web/app/controllers/api_users_controller.rb @@ -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? diff --git a/web/lib/user_manager.rb b/web/lib/user_manager.rb index 5fd12f487..ca00ef307 100644 --- a/web/lib/user_manager.rb +++ b/web/lib/user_manager.rb @@ -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