Merge branch 'rmarren1-master'

This commit is contained in:
Nick Winter 2015-02-16 17:38:47 -08:00
commit dc7cbb9c35
4 changed files with 14 additions and 2 deletions
app
collections
templates/editor/achievement
views/editor/achievement
server/commons

View file

@ -6,4 +6,5 @@ module.exports = class PatchesCollection extends CocoCollection
initialize: (models, options, forModel, @status='pending') ->
super(arguments...)
@url = "#{forModel.urlRoot}/#{forModel.get('original')}/patches?status=#{@status}"
identifier = if not forModel.get('original') then '_id' else 'original'
@url = "#{forModel.urlRoot}/#{forModel.get(identifier)}/patches?status=#{@status}"

View file

@ -23,6 +23,9 @@ block content
#achievement-view.clearfix
h3(data-i18n="resources.patches") Patches
.patches-view
hr
else

View file

@ -3,6 +3,7 @@ template = require 'templates/editor/achievement/edit'
Achievement = require 'models/Achievement'
AchievementPopup = require 'views/core/AchievementPopup'
ConfirmModal = require 'views/editor/modal/ConfirmModal'
PatchesView = require 'views/editor/PatchesView'
errors = require 'core/errors'
app = require 'core/application'
nodes = require 'views/editor/level/treema_nodes'
@ -57,6 +58,8 @@ module.exports = class AchievementEditView extends RootView
super()
return unless @supermodel.finished()
@pushChangesToPreview()
@patchesView = @insertSubView(new PatchesView(@achievement), @$el.find('.patches-view'))
@patchesView.load()
pushChangesToPreview: =>
return unless @treema

View file

@ -255,7 +255,12 @@ module.exports = class Handler
res.end()
getPatchesFor: (req, res, id) ->
query = { 'target.original': mongoose.Types.ObjectId(id), status: req.query.status or 'pending' }
query =
$or: [
{'target.original': id+''}
{'target.original': mongoose.Types.ObjectId(id)}
]
status: req.query.status or 'pending'
Patch.find(query).sort('-created').exec (err, patches) =>
return @sendDatabaseError(res, err) if err
patches = (patch.toObject() for patch in patches)