From 782aacf35eef331ef2b27685786a333f36b97e3f Mon Sep 17 00:00:00 2001 From: Rob Date: Mon, 25 Jul 2016 16:18:31 -0700 Subject: [PATCH] Patch Earned Achievements more generally. --- server/commons/mapping.coffee | 1 + server/handlers/earned_achievement_handler.coffee | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server/commons/mapping.coffee b/server/commons/mapping.coffee index 90069e32a..bf7dcc598 100644 --- a/server/commons/mapping.coffee +++ b/server/commons/mapping.coffee @@ -66,4 +66,5 @@ module.exports.modules = modules = # by collection name 'users': 'User' mongoose.modelNameByCollection = (collection) -> + return require('../models/LevelSession') if collection is 'level.session' mongoose.model modules[collection] if collection of modules diff --git a/server/handlers/earned_achievement_handler.coffee b/server/handlers/earned_achievement_handler.coffee index d5e2ef04d..4a609d5a9 100644 --- a/server/handlers/earned_achievement_handler.coffee +++ b/server/handlers/earned_achievement_handler.coffee @@ -51,9 +51,8 @@ class EarnedAchievementHandler extends Handler collection = req.body.collection if collection isnt 'level.sessions' return @sendBadInputError(res, 'Only doing level session achievements for now.') - #model = mongoose.modelNameByCollection(collection) - else - model = LevelSession + + model = mongoose.modelNameByCollection(collection) async.parallel({ achievement: (callback) ->