From 8233df514eb5aa000ea7c1aaaf63cf326c78786c Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Fri, 15 Aug 2014 10:35:35 -0700 Subject: [PATCH 1/3] Added an acceptor field to patches. --- app/schemas/models/patch.coffee | 1 + server/patches/patch_handler.coffee | 5 +++-- test/server/functional/patch.spec.coffee | 1 + 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/app/schemas/models/patch.coffee b/app/schemas/models/patch.coffee index bd4e822fe..918644c8b 100644 --- a/app/schemas/models/patch.coffee +++ b/app/schemas/models/patch.coffee @@ -6,6 +6,7 @@ PatchSchema = c.object({title: 'Patch', required: ['target', 'delta', 'commitMes delta: {title: 'Delta', type: ['array', 'object']} commitMessage: c.shortString({maxLength: 500, minLength: 1}) creator: c.objectId(links: [{rel: 'extra', href: '/db/user/{($)}'}]) + acceptor: c.objectId(links: [{rel: 'extra', href: '/db/user/{($)}'}]) created: c.date({title: 'Created', readOnly: true}) status: {enum: ['pending', 'accepted', 'rejected', 'withdrawn']} diff --git a/server/patches/patch_handler.coffee b/server/patches/patch_handler.coffee index 0226e18c4..12f34127b 100644 --- a/server/patches/patch_handler.coffee +++ b/server/patches/patch_handler.coffee @@ -53,9 +53,10 @@ PatchHandler = class PatchHandler extends Handler # Only increment statistics upon very first accept if patch.isNewlyAccepted() - accepter = req.user.get 'id' + patch.set 'acceptor', req.user.get('id') + acceptor = req.user.get 'id' submitter = patch.get 'creator' - User.incrementStat accepter, 'stats.patchesAccepted' + User.incrementStat acceptor, 'stats.patchesAccepted' # TODO maybe merge these increments together if patch.isTranslationPatch() User.incrementStat submitter, 'stats.totalTranslationPatches' diff --git a/test/server/functional/patch.spec.coffee b/test/server/functional/patch.spec.coffee index 798032e3c..08eaac60c 100644 --- a/test/server/functional/patch.spec.coffee +++ b/test/server/functional/patch.spec.coffee @@ -111,6 +111,7 @@ describe '/db/patch', -> expect(res.statusCode).toBe(200) Patch.findOne({}).exec (err, article) -> expect(article.get('status')).toBe 'accepted' + expect(article.get('acceptor')).toBeDefined() done() it 'keeps track of amount of submitted and accepted patches', (done) -> From 366dfadba5ed28d089d064b15eb04174d1a78d19 Mon Sep 17 00:00:00 2001 From: Scott Erickson Date: Fri, 15 Aug 2014 10:35:59 -0700 Subject: [PATCH 2/3] Fixed a bug in IDify. --- server/users/user_handler.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/users/user_handler.coffee b/server/users/user_handler.coffee index 85886726d..d96d86cf8 100644 --- a/server/users/user_handler.coffee +++ b/server/users/user_handler.coffee @@ -232,7 +232,7 @@ UserHandler = class UserHandler extends Handler IDify: (idOrSlug, done) -> return done null, idOrSlug if Handler.isID idOrSlug - User.getBySlug idOrSlug, (err, user) -> done err, user?.get '_id' + User.findBySlug idOrSlug, (err, user) -> done err, user?.get '_id' getLevelSessions: (req, res, userIDOrSlug) -> @IDify userIDOrSlug, (err, userID) => From ba1e7005cabae1a6bd43fa53ac4382d04fd28926 Mon Sep 17 00:00:00 2001 From: Nick Winter Date: Fri, 15 Aug 2014 10:50:05 -0700 Subject: [PATCH 3/3] Worked around issue with docs tab polluting supermodel for components to save. Another instance of #1108. Actually, same one, but the fix eralier got undone. --- app/views/editor/level/LevelEditView.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/editor/level/LevelEditView.coffee b/app/views/editor/level/LevelEditView.coffee index f7ee96c76..8461437e7 100644 --- a/app/views/editor/level/LevelEditView.coffee +++ b/app/views/editor/level/LevelEditView.coffee @@ -79,7 +79,7 @@ module.exports = class LevelEditView extends RootView @insertSubView new ComponentsTabView supermodel: @supermodel @insertSubView new SystemsTabView supermodel: @supermodel @insertSubView new RelatedAchievementsView supermodel: @supermodel, level: @level - @insertSubView new ComponentDocsView supermodel: @supermodel + @insertSubView new ComponentDocsView # Don't give it the supermodel, it'll pollute it! Backbone.Mediator.publish 'level-loaded', level: @level @showReadOnly() if me.get('anonymous')