Merge pull request #3330 from differentmatt/teacher-news

Add approved teacher trials to CodoCombat list Teachers group
This commit is contained in:
Scott Erickson 2016-01-18 15:18:55 -08:00
commit c23fb50fa7
7 changed files with 34 additions and 6 deletions

View file

@ -1037,6 +1037,7 @@
ambassador_title: "Ambassador"
ambassador_title_description: "(Support)"
ambassador_summary: "Tame our forum users and provide direction for those with questions. Our ambassadors represent CodeCombat to the world."
teacher_title: "Teacher"
editor:
main_title: "CodeCombat Editors"
@ -1193,6 +1194,7 @@
ambassador_join_note_strong: "Note"
ambassador_join_note_desc: "One of our top priorities is to build multiplayer where players having difficulty 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!"
ambassador_subscribe_desc: "Get emails on support updates and multiplayer developments."
teacher_subscribe_desc: "Get emails on updates and announcements for teachers."
changes_auto_save: "Changes are saved automatically when you toggle checkboxes."
diligent_scribes: "Our Diligent Scribes:"
powerful_archmages: "Our Powerful Archmages:"

View file

@ -79,6 +79,7 @@ _.extend UserSchema.properties,
archmageNews: {$ref: '#/definitions/emailSubscription'}
artisanNews: {$ref: '#/definitions/emailSubscription'}
diplomatNews: {$ref: '#/definitions/emailSubscription'}
teacherNews: {$ref: '#/definitions/emailSubscription'}
scribeNews: {$ref: '#/definitions/emailSubscription'}
# notifications

View file

@ -159,7 +159,7 @@ else
| (Translator)
input#email_diplomatNews(name="email_diplomatNews", type="checkbox", checked=subs.diplomatNews)
span(data-i18n="contribute.diplomat_subscribe_desc").help-block Get emails about i18n developments and, eventually, levels to translate.
.form-group.checkbox
label.control-label(for="email_ambassadorNews")
span(data-i18n="classes.ambassador_title")
@ -169,7 +169,13 @@ else
| (Support)
input#email_ambassadorNews(name="email_ambassadorNews", type="checkbox", checked=subs.ambassadorNews)
span(data-i18n="contribute.ambassador_subscribe_desc").help-block Get emails on support updates and multiplayer developments.
.form-group.checkbox
label.control-label(for="email_teacherNews")
span(data-i18n="classes.teacher_title")
input#email_teacherNews(name="email_teacherNews", type="checkbox", checked=subs.teacherNews)
span(data-i18n="contribute.teacher_subscribe_desc").help-block
button#toggle-all-btn.btn.btn-primary.form-control(data-i18n="account_settings.email_toggle") Toggle All
.panel.panel-default

View file

@ -3,6 +3,6 @@ config = require '../../server_config'
module.exports.MAILCHIMP_LIST_ID = 'e9851239eb'
module.exports.MAILCHIMP_GROUP_ID = '4529'
# these two need to be parallel
module.exports.MAILCHIMP_GROUPS = ['Announcements', 'Adventurers', 'Artisans', 'Archmages', 'Scribes', 'Diplomats', 'Ambassadors']
module.exports.NEWS_GROUPS = ['generalNews', 'adventurerNews', 'artisanNews', 'archmageNews', 'scribeNews', 'diplomatNews', 'ambassadorNews']
# These two need to be parallel
module.exports.MAILCHIMP_GROUPS = ['Announcements', 'Adventurers', 'Artisans', 'Archmages', 'Scribes', 'Diplomats', 'Ambassadors', 'Teachers']
module.exports.NEWS_GROUPS = ['generalNews', 'adventurerNews', 'artisanNews', 'archmageNews', 'scribeNews', 'diplomatNews', 'ambassadorNews', 'teacherNews']

View file

@ -5,6 +5,7 @@ hipchat = require '../hipchat'
sendwithus = require '../sendwithus'
Prepaid = require '../prepaids/Prepaid'
jsonSchema = require '../../app/schemas/models/trial_request.schema'
User = require '../users/User'
TrialRequestSchema = new mongoose.Schema {}, {strict: false, minimize: false, read:config.mongo.readpref}
@ -32,6 +33,19 @@ TrialRequestSchema.post 'save', (doc) ->
sendwithus.api.send emailParams, (err, result) =>
log.error "sendwithus trial request approved error: #{err}, result: #{result}" if err
# Subscribe to teacher news group
User.findById doc.get('applicant'), (err, user) =>
if err
log.error "Trial request user find error: #{err}"
return
emails = _.cloneDeep(user.get('emails') ? {})
emails.teacherNews ?= {}
emails.teacherNews.enabled = true
user.update {$set: {emails: emails}}, {}, (err) =>
if err
log.error "Trial request user update error: #{err}"
return
TrialRequestSchema.statics.privateProperties = []
TrialRequestSchema.statics.editableProperties = [
'created'

View file

@ -76,6 +76,7 @@ emailNameMap =
diplomatNews: 'translator'
ambassadorNews: 'support'
anyNotes: 'notification'
teacherNews: 'teacher'
UserSchema.methods.setEmailSubscription = (newName, enabled) ->
oldSubs = _.clone @get('emailSubscriptions')

View file

@ -134,7 +134,11 @@ describe 'Trial Requests', ->
expect(prepaid.get('type')).toEqual('course')
expect(prepaid.get('creator')).toEqual(user.get('_id'))
expect(prepaid.get('maxRedeemers')).toEqual(2)
done()
User.findById user._id, (err, user) =>
expect(err).toBeNull()
return done(err) if err
expect(user.get('emails')?.teacherNews?.enabled).toEqual(true)
done()
it 'Deny trial request', (done) ->
loginNewUser (user) ->