mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 09:35:39 -05:00
Add first/last names to Account Settings
This commit is contained in:
parent
e34abb0d27
commit
94e3c5a2b5
4 changed files with 27 additions and 7 deletions
|
@ -2,6 +2,8 @@
|
|||
|
||||
//- Fixed save button
|
||||
#site-content-area
|
||||
width: auto
|
||||
max-width: 1024px
|
||||
padding-bottom: 44px
|
||||
|
||||
#save-button-container
|
||||
|
@ -20,8 +22,6 @@
|
|||
opacity: 1.0
|
||||
|
||||
#account-settings-view
|
||||
|
||||
.row
|
||||
padding-top: 20px
|
||||
|
||||
//- Panels
|
||||
|
|
|
@ -10,15 +10,17 @@ else
|
|||
.panel-body
|
||||
.form
|
||||
- var name = me.get('name') || '';
|
||||
- var firstName = me.get('firstName') || '';
|
||||
- var lastName = me.get('lastName') || '';
|
||||
- var email = me.get('email') || '';
|
||||
- var admin = me.get('permissions', true).indexOf('admin') != -1;
|
||||
- var godmode = me.get('permissions', true).indexOf('godmode') != -1;
|
||||
.form-group
|
||||
label.control-label(for="name", data-i18n="general.name") Name
|
||||
label.control-label(for="name", data-i18n="general.username")
|
||||
input#name-input.form-control(name="name", type="text", value="#{name}")
|
||||
.form-group
|
||||
label.control-label(for="email")
|
||||
span(data-i18n="general.email") Email
|
||||
span(data-i18n="general.email")
|
||||
unless me.get('emailVerified')
|
||||
span.spl (
|
||||
span.spr(data-i18n="account.not_yet_verified")
|
||||
|
@ -27,12 +29,23 @@ else
|
|||
span.sent-text.hide(data-i18n="account.email_sent")
|
||||
span )
|
||||
input#email.form-control(name="email", type="text", value="#{email}")
|
||||
.row
|
||||
.form-group.col-sm-6
|
||||
label.control-label(for="firstName", data-i18n="general.first_name")
|
||||
input#first-name-input.form-control(name="firstName", type="text", value="#{firstName}")
|
||||
.form-group.col-sm-6
|
||||
if me.isStudent()
|
||||
label.control-label(for="lastName", data-i18n="general.last_initial")
|
||||
input#last-name-input.form-control(name="lastName", type="text", value="#{lastName}", maxlength="1")
|
||||
else
|
||||
label.control-label(for="lastName", data-i18n="general.last_name")
|
||||
input#last-name-input.form-control(name="lastName", type="text", value="#{lastName}")
|
||||
if !isProduction
|
||||
.form-group.checkbox
|
||||
label(for="admin", data-i18n="account_settings.admin") Admin
|
||||
label(for="admin", data-i18n="account_settings.admin")
|
||||
input#admin(name="admin", type="checkbox", checked=admin)
|
||||
.form-group.checkbox
|
||||
label(for="godmode", data-i18n="account_settings.god_mode") God Mode
|
||||
label(for="godmode", data-i18n="account_settings.god_mode")
|
||||
input#godmode(name="godmode", type="checkbox", checked=godmode)
|
||||
if me.hasSubscription()
|
||||
.form-group
|
||||
|
|
|
@ -266,6 +266,8 @@ module.exports = class AccountSettingsView extends CocoView
|
|||
grabOtherData: ->
|
||||
@$el.find('#name-input').val @suggestedName if @suggestedName
|
||||
me.set 'name', @$el.find('#name-input').val()
|
||||
me.set 'firstName', @$el.find('#first-name-input').val()
|
||||
me.set 'lastName', @$el.find('#last-name-input').val()
|
||||
me.set 'email', @$el.find('#email').val()
|
||||
for emailName, enabled of @getSubscriptions()
|
||||
me.setEmailSubscription emailName, enabled
|
||||
|
|
|
@ -370,6 +370,11 @@ UserSchema.pre('save', (next) ->
|
|||
@set('name', undefined)
|
||||
@set('nameLower', undefined)
|
||||
|
||||
if _.isEmpty(@get('firstName'))
|
||||
@set('firstName', undefined)
|
||||
if _.isEmpty(@get('lastName'))
|
||||
@set('lastName', undefined)
|
||||
|
||||
unless email or name or @get('anonymous') or @get('deleted')
|
||||
return next(new errors.UnprocessableEntity('User needs a username or email address'))
|
||||
|
||||
|
|
Loading…
Reference in a new issue