From 0ef50ccdb73419cf17cc6cb3e21f0cea2c03b051 Mon Sep 17 00:00:00 2001 From: Pablo Guijarro Ramirez Date: Fri, 18 Apr 2014 20:04:26 +0200 Subject: [PATCH 01/12] =?UTF-8?q?Traducido=20varios=20textos=20del=20fiche?= =?UTF-8?q?ro=20es-ES.coffe=20al=20espa=C3=B1ol=20de=20Espa=C3=B1a?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/locale/es-ES.coffee | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/locale/es-ES.coffee b/app/locale/es-ES.coffee index 730d883ea..44acd3f7c 100644 --- a/app/locale/es-ES.coffee +++ b/app/locale/es-ES.coffee @@ -3,10 +3,10 @@ module.exports = nativeDescription: "español (ES)", englishDescription: "Spanis loading: "Cargando..." saving: "Guardando..." sending: "Enviando..." -# send: "Send" + send: "Enviado" cancel: "Cancelar" save: "Guardar" -# publish: "Publish" + publish: "Publicado" create: "Crear" delay_1_sec: "1 segundo" delay_3_sec: "3 segundos" @@ -178,12 +178,12 @@ module.exports = nativeDescription: "español (ES)", englishDescription: "Spanis # approved: "Approved" # not_approved: "Not Approved" # looking_for: "Looking for:" -# last_updated: "Last updated:" -# contact: "Contact" + last_updated: "Última Actualización:" + contact: "Contacto" # work_experience: "Work Experience" -# education: "Education" -# our_notes: "Our Notes" -# projects: "Projects" + education: "Educación" + our_notes: "Nuestras notas" + projects: "Proyectos" # employers: # want_to_hire_our_players: "Want to hire expert CodeCombat players?" @@ -291,7 +291,7 @@ module.exports = nativeDescription: "español (ES)", englishDescription: "Spanis # time_current: "Now:" # time_total: "Max:" # time_goto: "Go to:" -# infinite_loop_try_again: "Try Again" + infinite_loop_try_again: "Intentar Otra Vez" # infinite_loop_reset_level: "Reset Level" # infinite_loop_comment_out: "Comment Out My Code" From 6a1d43435a2a3fe78412fb957ec8f3e389e574a1 Mon Sep 17 00:00:00 2001 From: JasperDhaene Date: Mon, 21 Apr 2014 19:50:43 +0200 Subject: [PATCH 02/12] fixed some lines to fit proper context --- app/locale/nl.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/locale/nl.coffee b/app/locale/nl.coffee index b69517de9..ac3e0c062 100644 --- a/app/locale/nl.coffee +++ b/app/locale/nl.coffee @@ -1,11 +1,11 @@ module.exports = nativeDescription: "Nederlands", englishDescription: "Dutch", translation: common: - loading: "Aan het laden..." + loading: "Bezig met laden..." saving: "Opslaan..." sending: "Verzenden..." send: "Verzend" cancel: "Annuleren" - save: "Opslagen" + save: "Opslaan" publish: "Publiceren" create: "Creëer" delay_1_sec: "1 seconde" @@ -46,7 +46,7 @@ module.exports = nativeDescription: "Nederlands", englishDescription: "Dutch", t employers: "Werkgevers" versions: - save_version_title: "Nieuwe versie opslagen" + save_version_title: "Nieuwe versie opslaan" new_major_version: "Nieuwe hoofd versie" cla_prefix: "Om bewerkingen op te slaan, moet je eerst akkoord gaan met onze" cla_url: "CLA" @@ -308,7 +308,7 @@ module.exports = nativeDescription: "Nederlands", englishDescription: "Dutch", t editor: main_title: "CodeCombat Editors" - main_description: "Maak je eigen levels, campagnes, eenheden en leermateriaal. Wij bieden alle programma's aan die u nodig heeft!" + main_description: "Maak je eigen levels, campagnes, eenheden en leermateriaal. Wij bieden alle programma's aan die je nodig hebt!" article_title: "Artikel Editor" article_description: "Schrijf artikels die spelers een overzicht geven over programmeer concepten die kunnen gebruikt worden over een variëteit van levels en campagnes." thang_title: "Thang Editor" From 4d7e6ba849b56e0e46c0214f77e4511ad332f998 Mon Sep 17 00:00:00 2001 From: JasperDhaene Date: Mon, 21 Apr 2014 19:52:27 +0200 Subject: [PATCH 03/12] fixed some lines to fit proper context --- app/locale/nl-BE.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/locale/nl-BE.coffee b/app/locale/nl-BE.coffee index 7fa0c3cde..f56beaf4f 100644 --- a/app/locale/nl-BE.coffee +++ b/app/locale/nl-BE.coffee @@ -1,11 +1,11 @@ module.exports = nativeDescription: "Nederlands (België)", englishDescription: "Dutch (Belgium)", translation: common: - loading: "Aan het laden..." + loading: "Bezig met laden..." saving: "Opslaan..." sending: "Verzenden..." send: "Verzend" cancel: "Annuleren" - save: "Opslagen" + save: "Opslaan" publish: "Publiceren" create: "Creëer" delay_1_sec: "1 seconde" @@ -46,7 +46,7 @@ module.exports = nativeDescription: "Nederlands (België)", englishDescription: employers: "Werkgevers" versions: - save_version_title: "Nieuwe versie opslagen" + save_version_title: "Nieuwe versie opslaan" new_major_version: "Nieuwe hoofd versie" cla_prefix: "Om bewerkingen op te slaan, moet je eerst akkoord gaan met onze" cla_url: "CLA" @@ -308,7 +308,7 @@ module.exports = nativeDescription: "Nederlands (België)", englishDescription: editor: main_title: "CodeCombat Editors" - main_description: "Maak je eigen levels, campagnes, eenheden en leermateriaal. Wij bieden alle programma's aan die u nodig heeft!" + main_description: "Maak je eigen levels, campagnes, eenheden en leermateriaal. Wij bieden alle programma's aan die je nodig hebt!" article_title: "Artikel Editor" article_description: "Schrijf artikels die spelers een overzicht geven over programmeer concepten die kunnen gebruikt worden over een variëteit van levels en campagnes." thang_title: "Thang Editor" From c49dc9457dc80ef744866aed68fa9bff9733d22a Mon Sep 17 00:00:00 2001 From: JasperDhaene Date: Mon, 21 Apr 2014 19:54:14 +0200 Subject: [PATCH 04/12] fixed some lines to fit proper context --- app/locale/nl-NL.coffee | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/locale/nl-NL.coffee b/app/locale/nl-NL.coffee index 9d74a74fb..73080f248 100644 --- a/app/locale/nl-NL.coffee +++ b/app/locale/nl-NL.coffee @@ -1,11 +1,11 @@ module.exports = nativeDescription: "Nederlands (Nederland)", englishDescription: "Dutch (Netherlands)", translation: common: - loading: "Aan het laden..." + loading: "Bezig met laden..." saving: "Opslaan..." sending: "Verzenden..." send: "Verzend" cancel: "Annuleren" - save: "Opslagen" + save: "Opslaan" publish: "Publiceren" create: "Creëer" delay_1_sec: "1 seconde" @@ -46,7 +46,7 @@ module.exports = nativeDescription: "Nederlands (Nederland)", englishDescription employers: "Werkgevers" versions: - save_version_title: "Nieuwe versie opslagen" + save_version_title: "Nieuwe versie opslaan" new_major_version: "Nieuwe hoofd versie" cla_prefix: "Om bewerkingen op te slaan, moet je eerst akkoord gaan met onze" cla_url: "CLA" @@ -308,7 +308,7 @@ module.exports = nativeDescription: "Nederlands (Nederland)", englishDescription editor: main_title: "CodeCombat Editors" - main_description: "Maak je eigen levels, campagnes, eenheden en leermateriaal. Wij bieden alle programma's aan die u nodig heeft!" + main_description: "Maak je eigen levels, campagnes, eenheden en leermateriaal. Wij bieden alle programma's aan die je nodig hebt!" article_title: "Artikel Editor" article_description: "Schrijf artikels die spelers een overzicht geven over programmeer concepten die kunnen gebruikt worden over een variëteit van levels en campagnes." thang_title: "Thang Editor" From e439e3fec814f0f1b4d57734f67e82e2297954e3 Mon Sep 17 00:00:00 2001 From: JasperDhaene Date: Mon, 21 Apr 2014 19:56:38 +0200 Subject: [PATCH 05/12] added missing i18n tag --- app/locale/en.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/app/locale/en.coffee b/app/locale/en.coffee index 4696d8dae..45aac3d7b 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -375,6 +375,7 @@ level_search_title: "Search Levels Here" signup_to_create: "Sign Up to Create a New Content" read_only_warning2: "Note: you can't save any edits here, because you're not logged in." + got_questions: "Questions about using the CodeCombat editors?" article: edit_btn_preview: "Preview" From afc447e596f0dbeba46e779dacfa7ada9fb0ba43 Mon Sep 17 00:00:00 2001 From: Glen De Cauwsemaecker Date: Tue, 22 Apr 2014 23:47:11 +0200 Subject: [PATCH 06/12] Removed double got_questions i18n tag in en.coffee from commit e439e3f --- app/locale/en.coffee | 1 - 1 file changed, 1 deletion(-) diff --git a/app/locale/en.coffee b/app/locale/en.coffee index 45aac3d7b..4696d8dae 100644 --- a/app/locale/en.coffee +++ b/app/locale/en.coffee @@ -375,7 +375,6 @@ level_search_title: "Search Levels Here" signup_to_create: "Sign Up to Create a New Content" read_only_warning2: "Note: you can't save any edits here, because you're not logged in." - got_questions: "Questions about using the CodeCombat editors?" article: edit_btn_preview: "Preview" From 5921575a02d47047f7071b21a66386127bed7a16 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 22 Apr 2014 16:42:41 -0700 Subject: [PATCH 07/12] Hack to fix a bug with the components view in the thang editor. --- app/views/editor/components/main.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/editor/components/main.coffee b/app/views/editor/components/main.coffee index 0104aa5d9..56e2ccac1 100644 --- a/app/views/editor/components/main.coffee +++ b/app/views/editor/components/main.coffee @@ -40,6 +40,7 @@ module.exports = class ThangComponentEditView extends CocoView @render() buildExtantComponentTreema: -> + new Level() # hack to load the schema treemaOptions = supermodel: @supermodel schema: Level.schema.properties.thangs.items.properties.components From c85971e5e6b152aa8e1ce1921e2ea9ca5395f639 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 22 Apr 2014 17:56:41 -0700 Subject: [PATCH 08/12] Added i18n population action to the level editor. --- app/lib/deltas.coffee | 2 +- app/models/CocoModel.coffee | 23 +++++++++++++++++++++++ app/templates/editor/level/edit.jade | 2 ++ app/treema-ext.coffee | 1 + app/views/editor/level/edit.coffee | 1 + 5 files changed, 28 insertions(+), 1 deletion(-) diff --git a/app/lib/deltas.coffee b/app/lib/deltas.coffee index de6d6c13b..e817551d1 100644 --- a/app/lib/deltas.coffee +++ b/app/lib/deltas.coffee @@ -68,7 +68,7 @@ expandFlattenedDelta = (delta, left, schema) -> parentLeft = left parentSchema = schema for key, i in delta.dataPath - # TODO: A more comprehensive way of getting child schemas + # TODO: Better schema/json walking childSchema = parentSchema?.items or parentSchema?.properties?[key] or {} childLeft = parentLeft?[key] humanKey = null diff --git a/app/models/CocoModel.coffee b/app/models/CocoModel.coffee index 3ecffd12e..1c93ea125 100644 --- a/app/models/CocoModel.coffee +++ b/app/models/CocoModel.coffee @@ -133,6 +133,7 @@ class CocoModel extends Backbone.Model schema ?= @schema() models = [] + # TODO: Better schema/json walking if $.isArray(data) and schema.items? for subData, i in data models = models.concat(@getReferencedModels(subData, schema.items, path+i+'/', shouldLoadProjection)) @@ -226,5 +227,27 @@ class CocoModel extends Backbone.Model watching: -> return me.id in (@get('watchers') or []) + + populateI18N: (data, schema, path='') -> + # TODO: Better schema/json walking + sum = 0 + data ?= $.extend true, {}, @attributes + schema ?= @schema() or {} + if schema.properties?.i18n and _.isPlainObject(data) and not data.i18n? + data.i18n = {} + sum += 1 + + if _.isPlainObject data + for key, value of data + numChanged = 0 + numChanged = @populateI18N(value, childSchema, path+'/'+key) if childSchema = schema.properties?[key] + if numChanged and not path # should only do this for the root object + @set key, value + sum += numChanged + + if schema.items and _.isArray data + sum += @populateI18N(value, schema.items, path+'/'+index) for value, index in data + + sum module.exports = CocoModel diff --git a/app/templates/editor/level/edit.jade b/app/templates/editor/level/edit.jade index 6b010912d..279b5086d 100644 --- a/app/templates/editor/level/edit.jade +++ b/app/templates/editor/level/edit.jade @@ -68,6 +68,8 @@ block header a(data-i18n="common.fork")#fork-level-start-button Fork li(class=anonymous ? "disabled": "") a(data-toggle="coco-modal", data-target="modal/revert", data-i18n="editor.revert")#revert-button Revert + li(class=anonymous ? "disabled": "") + a(data-i18n="editor.pop_i18n")#pop-level-i18n-button Populate i18n li.divider li.dropdown-header Info li#level-history-button diff --git a/app/treema-ext.coffee b/app/treema-ext.coffee index 62fb12644..e377ad665 100644 --- a/app/treema-ext.coffee +++ b/app/treema-ext.coffee @@ -233,6 +233,7 @@ class InternationalizationNode extends TreemaNode.nodeMap.object type: "object" properties: {} } + return i18nChildSchema unless @parent unless @schema.props? console.warn "i18n props array is empty! Filling with all parent properties by default" @schema.props = (prop for prop,_ of @parent.schema.properties when prop isnt "i18n") diff --git a/app/views/editor/level/edit.coffee b/app/views/editor/level/edit.coffee index 7cd112566..686ebd591 100644 --- a/app/views/editor/level/edit.coffee +++ b/app/views/editor/level/edit.coffee @@ -31,6 +31,7 @@ module.exports = class EditorLevelView extends View 'click #patches-tab': -> @patchesView.load() 'click #level-patch-button': 'startPatchingLevel' 'click #level-watch-button': 'toggleWatchLevel' + 'click #pop-level-i18n-button': -> @level.populateI18N() constructor: (options, @levelID) -> super options From f7035d4220ea82c2718ae48ffad596098cebe52f Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Tue, 22 Apr 2014 19:27:39 -0700 Subject: [PATCH 09/12] Added an unsubscribe url for recruit notifications. --- server/routes/auth.coffee | 24 +++++++++++++++++------- test/server/functional/auth.spec.coffee | 12 ++++++++++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/server/routes/auth.coffee b/server/routes/auth.coffee index e7aa44b67..3b5c30b1d 100644 --- a/server/routes/auth.coffee +++ b/server/routes/auth.coffee @@ -132,14 +132,24 @@ module.exports.setup = (app) -> return errors.notFound res, "No user found with email '#{req.query.email}'" emails = _.clone(user.get('emails')) or {} - emailSettings.enabled = false for emailSettings in _.values(emails) - emails.generalNews ?= {} - emails.generalNews.enabled = false - emails.anyNotes ?= {} - emails.anyNotes.enabled = false - user.update {$set: {emails: emails, emailSubscriptions: []}}, {}, => + msg = '' + + if req.query.recruitNotes + emails.recruitNotes ?= {} + emails.recruitNotes.enabled = false + msg = "Unsubscribed #{req.query.email} from recruiting emails." + + else + msg = "Unsubscribed #{req.query.email} from all CodeCombat emails. Sorry to see you go!" + emailSettings.enabled = false for emailSettings in _.values(emails) + emails.generalNews ?= {} + emails.generalNews.enabled = false + emails.anyNotes ?= {} + emails.anyNotes.enabled = false + + user.update {$set: {emails: emails}}, {}, => return errors.serverError res, 'Database failure.' if err - res.send "Unsubscribed #{req.query.email} from all CodeCombat emails. Sorry to see you go!

Account settings

" + res.send msg + "

Account settings

" res.end() module.exports.loginUser = loginUser = (req, res, user, send=true, next=null) -> diff --git a/test/server/functional/auth.spec.coffee b/test/server/functional/auth.spec.coffee index 750f4997e..6e5f5f07e 100644 --- a/test/server/functional/auth.spec.coffee +++ b/test/server/functional/auth.spec.coffee @@ -1,5 +1,6 @@ require '../common' request = require 'request' +User = require '../../../server/users/User' urlLogin = getURL('/auth/login') urlReset = getURL('/auth/reset') @@ -134,3 +135,14 @@ describe '/auth/reset', -> form = req.form() form.append('username', 'scott@gmail.com') form.append('password', 'nada') + +describe '/auth/unsubscribe', -> + + it 'removes just recruitment emails if you include ?recruitNotes=1', (done) -> + loginJoe (joe) -> + url = getURL('/auth/unsubscribe?recruitNotes=1&email='+joe.get('email')) + request.get url, (error, response) -> + expect(response.statusCode).toBe(200) + user = User.findOne(joe.get('_id')).exec (err, user) -> + expect(user.get('emails').recruitNotes.enabled).toBe(false) + done() From b390b3805449443ba2a55c3ce5cb6109763efc89 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 23 Apr 2014 09:19:07 -0700 Subject: [PATCH 10/12] Fixed a couple bugs and tests. --- server/users/User.coffee | 4 ++-- test/server/functional/auth.spec.coffee | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/server/users/User.coffee b/server/users/User.coffee index b62cf9b3c..1b591a304 100644 --- a/server/users/User.coffee +++ b/server/users/User.coffee @@ -47,7 +47,7 @@ UserSchema.methods.setEmailSubscription = (newName, enabled) -> oldSubs.push(oldName) if enabled @set('emailSubscriptions', oldSubs) - newSubs = _.clone(@get('emails') or jsonschema.properties.emails.default) + newSubs = _.clone(@get('emails') or _.cloneDeep(jsonschema.properties.emails.default)) newSubs[newName] ?= {} newSubs[newName].enabled = enabled @set('emails', newSubs) @@ -60,7 +60,7 @@ UserSchema.methods.isEmailSubscriptionEnabled = (newName) -> oldName = emailNameMap[newName] return oldName and oldName in oldSubs if oldSubs emails ?= {} - _.defaults emails, jsonschema.properties.emails.default + _.defaults emails, _.cloneDeep(jsonschema.properties.emails.default) return emails[newName]?.enabled UserSchema.statics.updateMailChimp = (doc, callback) -> diff --git a/test/server/functional/auth.spec.coffee b/test/server/functional/auth.spec.coffee index 6e5f5f07e..ce470288f 100644 --- a/test/server/functional/auth.spec.coffee +++ b/test/server/functional/auth.spec.coffee @@ -17,7 +17,8 @@ describe '/auth/whoami', -> describe '/auth/login', -> it 'clears Users first', (done) -> - User.remove {}, (err) -> + clearModels [User], (err) -> + throw err if err request.get getURL('/auth/whoami'), -> throw err if err done() @@ -137,6 +138,12 @@ describe '/auth/reset', -> form.append('password', 'nada') describe '/auth/unsubscribe', -> + it 'clears Users first', (done) -> + clearModels [User], (err) -> + throw err if err + request.get getURL('/auth/whoami'), -> + throw err if err + done() it 'removes just recruitment emails if you include ?recruitNotes=1', (done) -> loginJoe (joe) -> From 20541f55200b0c8e0bd2da1170204de576558a5f Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Wed, 23 Apr 2014 09:53:46 -0700 Subject: [PATCH 11/12] Added another check to the recruit unsubscribe test, to make sure it doesn't affect other subscriptions. --- test/server/functional/auth.spec.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/test/server/functional/auth.spec.coffee b/test/server/functional/auth.spec.coffee index ce470288f..15ef44171 100644 --- a/test/server/functional/auth.spec.coffee +++ b/test/server/functional/auth.spec.coffee @@ -152,4 +152,5 @@ describe '/auth/unsubscribe', -> expect(response.statusCode).toBe(200) user = User.findOne(joe.get('_id')).exec (err, user) -> expect(user.get('emails').recruitNotes.enabled).toBe(false) + expect(user.isEmailSubscriptionEnabled('generalNews')).toBeTruthy() done() From d4cf31c8fe453a6237d43be0a9382e58ef6bb8f6 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Wed, 23 Apr 2014 10:21:58 -0700 Subject: [PATCH 12/12] Improved admin view of pending candidates. --- app/lib/world/names.coffee | 16 ++++++++-------- app/lib/world/vector.coffee | 2 +- app/templates/employers.jade | 7 ++++++- scripts/mail.coffee | 3 ++- server/users/user_handler.coffee | 7 ++++--- 5 files changed, 21 insertions(+), 14 deletions(-) diff --git a/app/lib/world/names.coffee b/app/lib/world/names.coffee index fc0a6aff9..d52471998 100644 --- a/app/lib/world/names.coffee +++ b/app/lib/world/names.coffee @@ -69,25 +69,18 @@ module.exports.thangNames = thangNames = "Buffy" "Allankrita" ] - "Peasant": [ + "Peasant M": [ "Yorik" "Hector" "Thad" "Victor" "Lyle" "Charles" - "Mary" - "Brandy" - "Gwendolin" - "Tabitha" - "Regan" "Yusef" "Hingle" "Azgot" "Piers" "Carlton" - "Giselle" - "Bernadette" "Hershell" "Gawain" "Durfkor" @@ -99,6 +92,13 @@ module.exports.thangNames = thangNames = "Icey" "Matilda" "Mertia" + "Mary" + "Brandy" + "Gwendolin" + "Tabitha" + "Regan" + "Giselle" + "Bernadette" ] "Archer F": [ "Phoebe" diff --git a/app/lib/world/vector.coffee b/app/lib/world/vector.coffee index 72f761775..ed5112f2c 100644 --- a/app/lib/world/vector.coffee +++ b/app/lib/world/vector.coffee @@ -8,7 +8,7 @@ class Vector a.copy()[name](b, useZ) isVector: true - apiProperties: ['x', 'y', 'magnitude', 'heading', 'distance', 'dot', 'equals', 'copy'] + apiProperties: ['x', 'y', 'magnitude', 'heading', 'distance', 'dot', 'equals', 'copy', 'distanceSquared'] constructor: (@x=0, @y=0, @z=0) -> diff --git a/app/templates/employers.jade b/app/templates/employers.jade index efeb59429..bfb2ca051 100644 --- a/app/templates/employers.jade +++ b/app/templates/employers.jade @@ -28,6 +28,7 @@ block content th(data-i18n="employers.candidate_last_updated") Last Updated if me.isAdmin() th ✓? + th ಥ_ಥ tbody for candidate, index in candidates @@ -57,4 +58,8 @@ block content if candidate.get('jobProfileApproved') td ✓ else - td ✗ \ No newline at end of file + td ✗ + if profile.active + td ᶘ ᵒᴥᵒᶅ + else + td ⨂_⨂ \ No newline at end of file diff --git a/scripts/mail.coffee b/scripts/mail.coffee index 7d51fee76..b9983b619 100644 --- a/scripts/mail.coffee +++ b/scripts/mail.coffee @@ -77,7 +77,8 @@ grabUser = (session, callback) -> totalEmailsSent = 0 emailUser = (user, callback) -> - return callback null, false if user.emails?.recruiting?.enabled is false # TODO: later, obey also "announcements" when that's untangled + #return callback null, false if user.emails?.anyNotes?.enabled is false # TODO: later, uncomment to obey also "anyNotes" when that's untangled + return callback null, false if user.emails?.recruitNotes?.enabled is false return callback null, false if user.email in alreadyEmailed return callback null, false if DEBUGGING and (totalEmailsSent > 1 or Math.random() > 0.1) ++totalEmailsSent diff --git a/server/users/user_handler.coffee b/server/users/user_handler.coffee index 212ed7685..cc6f279d3 100644 --- a/server/users/user_handler.coffee +++ b/server/users/user_handler.coffee @@ -235,9 +235,10 @@ UserHandler = class UserHandler extends Handler getCandidates: (req, res) -> authorized = req.user.isAdmin() or ('employer' in req.user.get('permissions')) since = (new Date((new Date()) - 2 * 30.4 * 86400 * 1000)).toISOString() - query = {'jobProfile.active': true, 'jobProfile.updated': {$gt: since}} - #query = {'jobProfile.updated': {$gt: since}} + #query = {'jobProfile.active': true, 'jobProfile.updated': {$gt: since}} + query = {'jobProfile.updated': {$gt: since}} query.jobProfileApproved = true unless req.user.isAdmin() + query['jobProfile.active'] = true unless req.user.isAdmin() selection = 'jobProfile' selection += ' email' if authorized selection += ' jobProfileApproved' if req.user.isAdmin() @@ -251,7 +252,7 @@ UserHandler = class UserHandler extends Handler fields = if authorized then ['jobProfile', 'jobProfileApproved', 'photoURL', '_id'] else ['jobProfile'] obj = _.pick document.toObject(), fields obj.photoURL ||= obj.jobProfile.photoURL if authorized - subfields = ['country', 'city', 'lookingFor', 'jobTitle', 'skills', 'experience', 'updated'] + subfields = ['country', 'city', 'lookingFor', 'jobTitle', 'skills', 'experience', 'updated', 'active'] if authorized subfields = subfields.concat ['name'] obj.jobProfile = _.pick obj.jobProfile, subfields