From cb0375bc32ae3d2ad1f2fbc80f62c49e782babb7 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Thu, 14 Jun 2018 21:39:52 -0500 Subject: [PATCH] Add first name --- ruby/lib/jam_ruby/models/user.rb | 6 ++++++ web/app/assets/stylesheets/basic/basic.scss | 19 +++++++++++++++++++ web/app/controllers/landings_controller.rb | 10 +++++++++- .../landings/amazon_lessons_promo_2.slim | 12 ++++++++---- 4 files changed, 42 insertions(+), 5 deletions(-) diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb index 8f8147a53..ceb778ff7 100644 --- a/ruby/lib/jam_ruby/models/user.rb +++ b/ruby/lib/jam_ruby/models/user.rb @@ -559,9 +559,15 @@ module JamRuby first_name == 'Anonymous' && last_name == 'Anonymous' end + def is_last_anonymous? + first_name != 'Anonymous' && last_name == 'Anonymous' + end + def name if anonymous? 'Anonymous' + elsif is_last_anonymous? + "#{first_name}" else "#{first_name} #{last_name}" end diff --git a/web/app/assets/stylesheets/basic/basic.scss b/web/app/assets/stylesheets/basic/basic.scss index a4e271de2..81acb9e09 100644 --- a/web/app/assets/stylesheets/basic/basic.scss +++ b/web/app/assets/stylesheets/basic/basic.scss @@ -470,6 +470,19 @@ h2.second-ready { text-align:center; } +.email-row { + font-size: $standard-font-size; + + margin-top: 1rem; + display: flex; + align-items: center; + flex-direction: column; + + width: 100%; + max-width: 1200px; + text-align: center; +} + .password-row { font-size: $standard-font-size; @@ -576,6 +589,12 @@ input[type=submit] { } +label.first { + width:6rem; + margin-left:-6.5rem; +} + + label.email { width:6rem; margin-left:-6.5rem; diff --git a/web/app/controllers/landings_controller.rb b/web/app/controllers/landings_controller.rb index 15084ebe0..743fa9d6e 100644 --- a/web/app/controllers/landings_controller.rb +++ b/web/app/controllers/landings_controller.rb @@ -581,6 +581,14 @@ class LandingsController < ApplicationController else + + @first = params[:first] + if !@first || @first == '' + @error = 'Please specify first name' + render 'amazon_lessons_promo_2', layout: 'basic' + return + end + @instrument = params[:instrument] if @instrument.nil? || @instrument == '' @error = 'Please select an instrument' @@ -588,7 +596,6 @@ class LandingsController < ApplicationController return end - @email = params[:email] @password = params[:password] terms_of_service = params[:terms].nil? || params[:terms] == "0" ? false : true @@ -608,6 +615,7 @@ class LandingsController < ApplicationController skip_recaptcha: true, musician: true, timezone: current_timezone, + first_name: @first, instruments: [{:instrument_id => @instrument, :proficiency_level => 1, :priority => 1}]) if @user.errors.any? first = @user.errors.first diff --git a/web/app/views/landings/amazon_lessons_promo_2.slim b/web/app/views/landings/amazon_lessons_promo_2.slim index 10a81b51c..5a48affbe 100644 --- a/web/app/views/landings/amazon_lessons_promo_2.slim +++ b/web/app/views/landings/amazon_lessons_promo_2.slim @@ -33,13 +33,17 @@ form#root method='POST' action='/account/activate/signup' .code-form.create-account .text-input - label.code-prompt.email - = 'Email:' + label.code-prompt.first + = 'First Name:' - if @error .error = @error - + input autofocus='autofocus' type='text' name='first' value=@first + .email-row + .text-input + label.code-prompt.email + = 'Email:' input type='hidden' name='code' value=@code - input autofocus='autofocus' type='text' name='email' value=@email + input type='text' name='email' value=@email .password-row .text-input label.code-prompt.password