diff options
| author | Jules Laplace <jules@okfoc.us> | 2014-10-10 16:00:01 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2014-10-10 16:00:01 -0400 |
| commit | b35bda803440233b68389603bbaced53f8bb18ba (patch) | |
| tree | d1ca48fb651307799cb33cb766b0988a5613043f /server | |
| parent | 12b7f63b9d6687b3177bf30a212fdf856864b4f5 (diff) | |
| parent | 8990307ff8f90007b59cf778d2b3da0372dedf14 (diff) | |
merge
Diffstat (limited to 'server')
| -rw-r--r-- | server/lib/api/projects.js | 21 | ||||
| -rw-r--r-- | server/lib/views/index.js | 1 |
2 files changed, 13 insertions, 9 deletions
diff --git a/server/lib/api/projects.js b/server/lib/api/projects.js index 61a6e10..c04f4f6 100644 --- a/server/lib/api/projects.js +++ b/server/lib/api/projects.js @@ -34,7 +34,7 @@ var projects = { data.user_id = req.user._id data.name = util.sanitize(data.name) - data.slug = util.slugify(data.name) + data.slug = util.slugify(data.name) + "-" + (+new Date) data.description = util.sanitize(data.description) data.rooms = JSON.parse(data.rooms) data.walls = JSON.parse(data.walls) @@ -67,14 +67,6 @@ var projects = { return docs.create(req, res) } - var data = util.cleanQuery(req.body) - - // data.user_id = req.user._id - data.name = util.sanitize(data.name) - data.slug = util.slugify(data.name) - data.description = util.sanitize(data.description) - data.updated_at = new Date () - if (req.files.thumbnail) { upload.put("projects", req.files.thumbnail, { unacceptable: function(err){ @@ -93,6 +85,17 @@ var projects = { function done() { Project.findOne({ _id: _id }, function(err, doc){ if (err || ! doc) { return res.json({ error: err }) } + + var data = util.cleanQuery(req.body) + + // data.user_id = req.user._id + data.name = util.sanitize(data.name) + if (data.name != doc.name) { + data.slug = util.slugify(data.name) + "-" + (+new Date) + } + data.description = util.sanitize(data.description) + data.updated_at = new Date () + _.extend(doc, data) doc.rooms = JSON.parse(data.rooms) diff --git a/server/lib/views/index.js b/server/lib/views/index.js index 637b061..5b1a72e 100644 --- a/server/lib/views/index.js +++ b/server/lib/views/index.js @@ -165,6 +165,7 @@ var views = module.exports = { function done(err, user, projects){ if (! user) { return res.redirect('/') } res.render('profile', { + isOwnProfile: String(user._id) == (req.user && String(req.user._id)), profile: user, projects: projects || [], }) |
