Skip to content
Browse files

node 0.6.x fixes.

  • Loading branch information...
1 parent aaed479 commit d4b3c7e85748d6cfa70d442243e496dd8d37c4f0 Adrian Rossouw committed Mar 28, 2012
Showing with 16 additions and 16 deletions.
  1. +5 −4 lib/document.js
  2. +0 −1 lib/forms.js
  3. +11 −11 pages.js
View
9 lib/document.js
@@ -226,7 +226,7 @@ Document.prototype.renderActions = function() {
{ title: 'Delete', path: '/delete/' + this.data._id},
{ title: 'New', path: '/new/' + this.data.type}
],
- _template: view('list'),
+ _template: 'list',
class: 'actions'
};
};
@@ -268,10 +268,11 @@ Document.prototype.render = function(req) {
_template: 'entry',
items: output
},
- suppressTitle: true,
+ actions: {},
+ suppressTitle: true
};
- if (user.permission(req, 'manage_content')) {
+ if (user.authenticated(req)) {
locals.actions = this.renderActions();
}
@@ -297,7 +298,7 @@ Document.prototype.renderForm = function(req, form) {
if (this.data._id) {
locals.title =
locals.pageTitle = 'Edit ' + strip_tags(this.data.field_title);
- if (user.permission(req, 'manage_content')) {
+ if (user.authenticated(req)) {
locals.actions = this.renderActions();
}
}
View
1 lib/forms.js
@@ -144,7 +144,6 @@ EditDocumentForm.on('success', function(req, res, track) {
this.document.update(
track(function(err, doc) {
req.form.redirect = '/' + doc.data._id;
- res.redirect('/' + doc.data._id);
})
);
});
View
22 pages.js
@@ -21,23 +21,16 @@ app.get('/*', document.documentLoader, function(req, res, next) {
});
/**
- * Expose new form.
- */
-app.get('/new/*', document.forms.new.load(), function(req, res) {
- req.form.render(req, res);
-});
-
-/**
* Handle submission of new form.
*/
app.post('/new/*', document.forms.new.load(), function(req, res) {
req.form.process(req, res);
});
/**
- * Expose edit form.
+ * Expose new form.
*/
-app.get('/edit/*', document.forms.edit.load(), function(req, res) {
+app.get('/new/*', document.forms.new.load(), function(req, res) {
req.form.render(req, res);
});
@@ -49,9 +42,9 @@ app.post('/edit/*', document.forms.edit.load(), function(req, res) {
});
/**
- * Expose delete form.
+ * Expose edit form.
*/
-app.get('/delete/*', document.forms.delete.load(), function(req, res) {
+app.get('/edit/*', document.forms.edit.load(), function(req, res) {
req.form.render(req, res);
});
@@ -61,3 +54,10 @@ app.get('/delete/*', document.forms.delete.load(), function(req, res) {
app.post('/delete/*', document.forms.delete.load(), function(req, res) {
req.form.process(req, res);
});
+/**
+ * Expose delete form.
+ */
+app.get('/delete/*', document.forms.delete.load(), function(req, res) {
+ req.form.render(req, res);
+});
+

0 comments on commit d4b3c7e

Please sign in to comment.
Something went wrong with that request. Please try again.