Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Privacy: teacher sign-up has email preference #22283

Merged
merged 2 commits into from May 10, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/src/sites/studio/pages/signup.js
Expand Up @@ -155,6 +155,7 @@ window.SignupManager = function (options) {
$("#name-student").fadeIn();
$("#name-teacher").hide();
setSchoolInfoVisibility(false);
$(".email-preference").hide();

// Show correct terms below form.
$("#student-terms").fadeIn();
Expand Down Expand Up @@ -251,6 +252,7 @@ window.SignupManager = function (options) {
$("#name-student").hide();
$("#name-teacher").fadeIn();
setSchoolInfoVisibility(true);
$(".email-preference").fadeIn();

// Show correct terms below form.
$("#student-terms").hide();
Expand Down
15 changes: 15 additions & 0 deletions dashboard/app/assets/stylesheets/application.scss
Expand Up @@ -1589,12 +1589,27 @@ a.download-video {
}
.itemblock {
display: table;

input[type=radio] {
margin-top: -4px;
margin-right: 4px;
}

label {
display: inline-block;
}
}
.labelblock {
display: table-cell;
width: 140px;
vertical-align: middle;
}
.labelblock-wide {
display: table-cell;
width: 350px;
padding-right: 10px;
vertical-align: middle;
}
.school-info-labelblock {
display: table-cell;
width: 210px;
Expand Down
12 changes: 12 additions & 0 deletions dashboard/app/controllers/registrations_controller.rb
Expand Up @@ -38,6 +38,18 @@ def create
storage_id = take_storage_id_ownership_from_cookie(current_user.id)
current_user.generate_progress_from_storage_id(storage_id) if storage_id
end

if current_user && current_user.teacher?
# While a/b testing, one of two possible fields might come through.
optin_value = params[:email_preference] == "yes" || params[:email_preference2] == "yes"
EmailPreference.upsert!(
email: params[:user][:email],
opt_in: optin_value,
ip_address: request.env['REMOTE_ADDR'],
source: "Teacher account sign up",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After I merge #22277, this would change to EmailPreference::REGISTRATION

form_kind: "0"
)
end
end

# Set age for the current user if empty - skips CSRF verification because this can be called
Expand Down
22 changes: 22 additions & 0 deletions dashboard/app/views/devise/registrations/new.html.haml
Expand Up @@ -15,6 +15,8 @@

- user_return_to_url = get_and_clear_session_user_return_to

%script{src: "https://cdn.optimizely.com/js/400912536.js"}

#signup
.row
.span9
Expand Down Expand Up @@ -80,6 +82,26 @@
= f.select :gender, gender_options, {disabled: '', selected: ''}, {class: 'fieldblock'}
.error_in_field

#optin-container
#optin-block.itemblock.email-preference{style: "display: none"}
.labelblock-wide= t('signup_form.email_preference_question').html_safe
%select.fieldblock{name: "email_preference", type: "select"}
%option{value: "", selected: true, disabled: true}
%option{value: "yes"}= t('signup_form.email_preference_yes').html_safe
%option{value: "no"}= t('signup_form.email_preference_no').html_safe
.error_in_field

#optin2-container{style: "display: none"}
#optin2-block.itemblock.email-preference
.labelblock-wide= t('signup_form.email_preference_question').html_safe
#optin2-yes-container
%input{type: "radio", id: "optin2-yes", name: "email_preference2", value: "yes"}
%label{for: "optin2-yes"}= t('signup_form.email_preference_yes').html_safe
#optin2-no-container
%input{type: "radio", id: "optin2-no", name: "email_preference2", value: "no"}
%label{for: "optin2-no"}= t('signup_form.email_preference_no').html_safe
.error_in_field

#teacher-terms{style: 'display: none'}
.right
%iframe#print-frame{src: '/terms-and-privacy', style: 'display: none'}
Expand Down
3 changes: 3 additions & 0 deletions dashboard/config/locales/en.yml
Expand Up @@ -145,6 +145,9 @@ en:
field_is_required: "is required"
accept_terms: "You must agree to create an account"
error: "An error occurred."
email_preference_question: "Can we email you about updates to our courses, local learning opportunities, or other computer science news?"
email_preference_yes: "Yes"
email_preference_no: "No"
school_info:
title: 'School Information (optional)'
school_country: 'School Country'
Expand Down