mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2025-03-14 07:00:01 -04:00
Add birthday field to user that rejects users under 13 on signup.
This commit is contained in:
parent
fdc3c0d0d4
commit
4183764b61
7 changed files with 79 additions and 12 deletions
|
@ -235,6 +235,7 @@
|
|||
connected_facebook_p: "Finish signing up so you can log in with your Facebook account."
|
||||
facebook_exists: "You already have an account associated with Facebook!"
|
||||
hey_students: "Students, enter the class code from your teacher."
|
||||
birthday: "Birthday"
|
||||
|
||||
recover:
|
||||
recover_account_title: "Recover Account"
|
||||
|
@ -1661,6 +1662,11 @@
|
|||
you_can2: "purchase a prepaid code"
|
||||
you_can3: "that can be applied to your own account or given to others."
|
||||
|
||||
coppa_deny:
|
||||
text1: "Can’t wait to learn programming?"
|
||||
text2: "Ask your parents to create an account for you!"
|
||||
close: "Close Window"
|
||||
|
||||
loading_error:
|
||||
could_not_load: "Error loading from server"
|
||||
connection_failure: "Connection Failed"
|
||||
|
@ -1813,3 +1819,17 @@
|
|||
one_month_discount: "discount, 30% off: choose either Rails or HTML"
|
||||
license: "license"
|
||||
oreilly: "ebook of your choice"
|
||||
|
||||
calendar:
|
||||
january: "January"
|
||||
february: "February"
|
||||
march: "March"
|
||||
april: "April"
|
||||
may: "May"
|
||||
june: "June"
|
||||
july: "July"
|
||||
august: "August"
|
||||
september: "September"
|
||||
october: "October"
|
||||
november: "November"
|
||||
december: "December"
|
||||
|
|
|
@ -328,6 +328,7 @@ _.extend UserSchema.properties,
|
|||
})
|
||||
schoolName: {type: 'string'}
|
||||
role: {type: 'string', enum: ["God", "advisor", "parent", "principal", "student", "superintendent", "teacher", "technology coordinator"]}
|
||||
birthday: c.stringDate({title: "Birthday"})
|
||||
|
||||
c.extendBasicProperties UserSchema, 'user'
|
||||
|
||||
|
|
11
app/templates/core/coppa-deny.jade
Normal file
11
app/templates/core/coppa-deny.jade
Normal file
|
@ -0,0 +1,11 @@
|
|||
extends /templates/core/modal-base
|
||||
|
||||
block modal-header-content
|
||||
|
||||
block modal-body-content
|
||||
p
|
||||
h2(data-i18n="coppa_deny.text1")
|
||||
div(data-i18n="coppa_deny.text2")
|
||||
|
||||
block modal-footer-content
|
||||
a(href='#', data-dismiss="modal", aria-hidden="true", data-i18n="coppa_deny.close").btn
|
|
@ -62,7 +62,7 @@
|
|||
.col-md-6
|
||||
.form-group
|
||||
label.control-label(for="name")
|
||||
span(data-i18n="general.name") Name
|
||||
span(data-i18n="general.username")
|
||||
| :
|
||||
.input-border
|
||||
if me.get('name')
|
||||
|
@ -71,15 +71,23 @@
|
|||
input#name.input-large.form-control(name="name", type="text", value="", placeholder="e.g. Alex W the Skater", tabindex=3)
|
||||
|
||||
.form-group
|
||||
label.control-label(for="school-input")
|
||||
span.spr(data-i18n="signup.school_name")
|
||||
em.optional-note
|
||||
| (
|
||||
span(data-i18n="signup.optional")
|
||||
| ):
|
||||
label.control-label(for="birthday-input")
|
||||
span(data-i18n="signup.birthday")
|
||||
| :
|
||||
.input-border
|
||||
input#school-input.input-large.form-control(name="schoolName", data-i18n="[placeholder]signup.school_name_placeholder", value=view.previousFormInputs.schoolName || '', tabindex=4)
|
||||
|
||||
select#birthday-month-input.input-large.form-control(name="birthdayMonth", value=view.previousFormInputs.birthdayMonth || '', tabindex=4, style="width: 120px; float: left")
|
||||
option Month
|
||||
for name, val in ['january','february','march','april','may','june','july','august','september','october','november','december']
|
||||
option(data-i18n="calendar.#{name}" value=val+1)
|
||||
select#birthday-day-input.input-large.form-control(name="birthdayDay", value=view.previousFormInputs.birthdayDay || '', tabindex=5, style="width: 55px; float: left")
|
||||
option Day
|
||||
for dummy, val in new Array(31)
|
||||
option #{val+1}
|
||||
select#birthday-year-input.input-large.form-control(name="birthdayYear", value=view.previousFormInputs.birthdayMonth || '', tabindex=6, style="width: 100px;")
|
||||
option Year
|
||||
for dummy, val in new Array(30)
|
||||
option #{2016-29+val}
|
||||
|
||||
.form-group
|
||||
label.control-label(for="school-input")
|
||||
span.spr(data-i18n="courses.class_code")
|
||||
|
@ -88,7 +96,7 @@
|
|||
span(data-i18n="signup.optional")
|
||||
| ):
|
||||
.input-border
|
||||
input#class-code-input.input-large.form-control(name="classCode", value=view.previousFormInputs.classCode || '', tabindex=5)
|
||||
input#class-code-input.input-large.form-control(name="classCode", value=view.previousFormInputs.classCode || '', tabindex=7)
|
||||
|
||||
.col-md-6
|
||||
.form-group.checkbox
|
||||
|
|
8
app/views/core/COPPADenyModal.coffee
Normal file
8
app/views/core/COPPADenyModal.coffee
Normal file
|
@ -0,0 +1,8 @@
|
|||
ModalView = require 'views/core/ModalView'
|
||||
template = require 'templates/core/coppa-deny'
|
||||
|
||||
|
||||
module.exports = class COPPADenyModal extends ModalView
|
||||
id: 'coppa-deny-modal'
|
||||
template: template
|
||||
closeButton: true
|
|
@ -6,6 +6,7 @@ User = require 'models/User'
|
|||
application = require 'core/application'
|
||||
Classroom = require 'models/Classroom'
|
||||
errors = require 'core/errors'
|
||||
COPPADenyModal = require 'views/core/COPPADenyModal'
|
||||
|
||||
|
||||
module.exports = class CreateAccountModal extends ModalView
|
||||
|
@ -56,6 +57,21 @@ module.exports = class CreateAccountModal extends ModalView
|
|||
attrs.emails.generalNews.enabled = @$el.find('#subscribe').prop('checked')
|
||||
@classCode = attrs.classCode
|
||||
delete attrs.classCode
|
||||
|
||||
|
||||
birthday = new Date Date.UTC attrs.birthdayYear, attrs.birthdayMonth - 1, attrs.birthdayDay
|
||||
if isNaN(birthday.getTime())
|
||||
forms.setErrorToProperty @$el, 'birthdayDay', 'Required'
|
||||
error = true
|
||||
else
|
||||
age = (new Date().getTime() - birthday.getTime()) / 365.4 / 24 / 60 / 60 / 1000
|
||||
if age >= 13
|
||||
attrs.birthday = birthday.toISOString()
|
||||
|
||||
delete attrs.birthdayYear
|
||||
delete attrs.birthdayMonth
|
||||
delete attrs.birthdayDay
|
||||
|
||||
_.assign attrs, @gplusAttrs if @gplusAttrs
|
||||
_.assign attrs, @facebookAttrs if @facebookAttrs
|
||||
res = tv4.validateMultiple attrs, User.schema
|
||||
|
@ -76,7 +92,10 @@ module.exports = class CreateAccountModal extends ModalView
|
|||
if @classCode
|
||||
@signupClassroomPrecheck()
|
||||
else
|
||||
@createUser()
|
||||
if age < 13
|
||||
@openModalView new COPPADenyModal
|
||||
else
|
||||
@createUser()
|
||||
|
||||
signupClassroomPrecheck: ->
|
||||
classroom = new Classroom()
|
||||
|
|
|
@ -343,7 +343,7 @@ UserSchema.statics.editableProperties = [
|
|||
'firstName', 'lastName', 'gender', 'ageRange', 'facebookID', 'gplusID', 'emails',
|
||||
'testGroupNumber', 'music', 'hourOfCode', 'hourOfCodeComplete', 'preferredLanguage',
|
||||
'wizard', 'aceConfig', 'autocastDelay', 'lastLevel', 'jobProfile', 'savedEmployerFilterAlerts',
|
||||
'heroConfig', 'iosIdentifierForVendor', 'siteref', 'referrer', 'schoolName', 'role'
|
||||
'heroConfig', 'iosIdentifierForVendor', 'siteref', 'referrer', 'schoolName', 'role', 'birthday'
|
||||
]
|
||||
|
||||
UserSchema.statics.serverProperties = ['passwordHash', 'emailLower', 'nameLower', 'passwordReset', 'lastIP']
|
||||
|
|
Loading…
Reference in a new issue