ContentVersion.findById(id,function(err,version) { if(err && !version) { calipso.err(err); next(); return; } // Copy over Content.findById(contentId,function(err,content) { if(err && !content) { calipso.err(err) next(); return; } calipso.form.mapFields(version.doc,content); content.author = req.session.user.username; content.set("comment",'Reverted to version: ' + content.updated); content.updated = new Date(); content.set("version",'Yes'); content.save(function(err) { res.redirect('/content/show/' + contentId); next(); }); }); });
ContentVersion.findById(id,function(err,version) { if(err && !version) { calipso.err(err); next(); return; } if(format === 'html') { calipso.theme.renderItem(req,res,template,block,{version:version},next); } if(format === 'json') { res.format = format; res.send(version.map(function(u) { return u.toObject(); })); next(); } });