Allowed access to character class emails by prompting for signup on check.

This commit is contained in:
Nick Winter 2014-01-05 14:20:48 -08:00
parent f0989b67c9
commit ec20cac6f7
3 changed files with 28 additions and 28 deletions

View file

@ -110,10 +110,9 @@ block content
| , tell us a little about yourself, what you've done and what you'd | , tell us a little about yourself, what you've done and what you'd
| be interested in working on. We'll go from there! | be interested in working on. We'll go from there!
if !me.attributes.anonymous label.checkbox(for="developer").well
label.checkbox(for="developer").well input(type='checkbox', name="developer", id="developer")
input(type='checkbox', name="developer", id="developer") | Get emails on new coding opportunities and announcements.
| Get emails on new coding opportunities and announcements.
#artisan #artisan
@ -148,10 +147,9 @@ block content
a(href="https://docs.google.com/document/d/117tMcL95T1KY8BDisr0iGi5Frb2ZvBJTC0us5hyQkJY/edit?usp=sharing") preliminary documentation a(href="https://docs.google.com/document/d/117tMcL95T1KY8BDisr0iGi5Frb2ZvBJTC0us5hyQkJY/edit?usp=sharing") preliminary documentation
| for more info, and please comment on it so we can make the whole system better. | for more info, and please comment on it so we can make the whole system better.
if !me.attributes.anonymous label.checkbox(for="level_creator").well
label.checkbox(for="level_creator").well input(type='checkbox', name="level_creator", id="level_creator")
input(type='checkbox', name="level_creator", id="level_creator") | Get emails on level editor updates and announcements.
| Get emails on level editor updates and announcements.
#adventurer #adventurer
@ -188,10 +186,9 @@ block content
a(href="https://plus.google.com/115285980638641924488/posts") Google+ a(href="https://plus.google.com/115285980638641924488/posts") Google+
| , so if you prefer to be notified those ways, sign up there! | , so if you prefer to be notified those ways, sign up there!
if !me.attributes.anonymous label.checkbox(for="tester").well
label.checkbox(for="tester").well input(type='checkbox', name="tester", id="tester")
input(type='checkbox', name="tester", id="tester") | Get emails when there are new levels to test.
| Get emails when there are new levels to test.
#scribe #scribe
@ -220,10 +217,9 @@ block content
| , tell us a little about yourself, your experience with programming and | , tell us a little about yourself, your experience with programming and
| what sort of things you'd like to write about. We'll go from there! | what sort of things you'd like to write about. We'll go from there!
if !me.attributes.anonymous label.checkbox(for="article_editor").well
label.checkbox(for="article_editor").well input(type='checkbox', name="article_editor", id="article_editor")
input(type='checkbox', name="article_editor", id="article_editor") | Get emails about article writing announcements.
| Get emails about article writing announcements.
@ -253,10 +249,9 @@ block content
| , so check it out and add things for your language. Also, check this box below to | , so check it out and add things for your language. Also, check this box below to
| keep up-to-date on new internationalization developments! | keep up-to-date on new internationalization developments!
if !me.attributes.anonymous label.checkbox(for="translator").well
label.checkbox(for="translator").well input(type='checkbox', name="translator", id="translator")
input(type='checkbox', name="translator", id="translator") | Get emails about i18n developments and levels to translate.
| Get emails about i18n developments and levels to translate.
#ambassador #ambassador
@ -289,10 +284,9 @@ block content
| solving levels can summon higher level wizards to help them. | solving levels can summon higher level wizards to help them.
| This will be a great way for ambassadors to do their thing. We'll keep you posted! | This will be a great way for ambassadors to do their thing. We'll keep you posted!
if !me.attributes.anonymous label.checkbox(for="support").well
label.checkbox(for="support").well input(type='checkbox', name="support", id="support")
input(type='checkbox', name="support", id="support") | Get emails on support updates and multiplayer developments.
| Get emails on support updates and multiplayer developments.
#counselor #counselor

View file

@ -1,6 +1,7 @@
View = require 'views/kinds/RootView' View = require 'views/kinds/RootView'
template = require 'templates/contribute' template = require 'templates/contribute'
{me} = require('lib/auth') {me} = require 'lib/auth'
SignupModalView = require 'views/modal/signup_modal'
module.exports = class ContributeView extends View module.exports = class ContributeView extends View
id: "contribute-view" id: "contribute-view"
@ -21,9 +22,11 @@ module.exports = class ContributeView extends View
el = $(e.target) el = $(e.target)
checked = el.prop('checked') checked = el.prop('checked')
subscription = el.attr('name') subscription = el.attr('name')
subscriptions = me.get('emailSubscriptions') subscriptions = me.get('emailSubscriptions') ? []
if checked and not (subscription in subscriptions) if checked and not (subscription in subscriptions)
subscriptions.push(subscription) subscriptions.push(subscription)
if me.get 'anonymous'
@openModalView new SignupModalView()
if not checked if not checked
subscriptions = _.without subscriptions, subscription subscriptions = _.without subscriptions, subscription

View file

@ -44,10 +44,13 @@ module.exports = class SignupModalView extends View
userObject = forms.formToObject @$el userObject = forms.formToObject @$el
delete userObject.subscribe delete userObject.subscribe
delete userObject["confirm-age"] delete userObject["confirm-age"]
for key, val of me.attributes when key in ["preferredLanguage", "testGroupNumber", "dateCreated", "wizardColor1", "name", "music", "volume"] for key, val of me.attributes when key in ["preferredLanguage", "testGroupNumber", "dateCreated", "wizardColor1", "name", "music", "volume", "emailSubscriptions"]
userObject[key] ?= val userObject[key] ?= val
subscribe = @$el.find('#signup-subscribe').prop('checked') subscribe = @$el.find('#signup-subscribe').prop('checked')
userObject.emailSubscriptions = if subscribe then ['announcement'] else [] if subscribe
(userObject.emailSubscriptions ?= []).push 'announcement'
else
userObject.emailSubscriptions = _.without (userObject.emailSubscriptions ? []), 'announcement'
res = tv4.validateMultiple userObject, User.schema.attributes res = tv4.validateMultiple userObject, User.schema.attributes
return forms.applyErrorsToForm(@$el, res.errors) unless res.valid return forms.applyErrorsToForm(@$el, res.errors) unless res.valid
window.tracker?.trackEvent 'Finished Signup' window.tracker?.trackEvent 'Finished Signup'