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/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') 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/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) => 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) ->