From 422bdf24c80e205cda11d74ebc7bd54975e3ac20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Neto?= Date: Thu, 5 Feb 2015 20:09:10 -0200 Subject: [PATCH] Adds owner's name and email on talk's edit and detail screen. --- controller/talk.js | 4 ++-- routes/index.js | 2 +- views/talk-detail.jade | 6 ++++++ views/talk-edit.jade | 6 ++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/controller/talk.js b/controller/talk.js index a9a1c09..bb1960f 100644 --- a/controller/talk.js +++ b/controller/talk.js @@ -3,10 +3,10 @@ var Talk = require('../models/talk'); module.exports = function() { return { list: function(filters, callback) { - Talk.find(filters).populate('event').exec(callback); + Talk.find(filters).populate('event owner').exec(callback); }, get: function(id, callback) { - Talk.findById(id).populate('event').exec(callback); + Talk.findById(id).populate('event owner').exec(callback); }, new: function(talk, userLogged) { var newTalk = new Talk(); diff --git a/routes/index.js b/routes/index.js index 946a339..3e6bfe2 100644 --- a/routes/index.js +++ b/routes/index.js @@ -63,7 +63,7 @@ var setEventIsDeleteableAndUpdatable = function(event, userLogged) { } var setTalkIsDeleteableAndUpdatable = function(talk, userLogged) { - if (talk.owner == userLogged._id.toString()) { + if (talk.owner._id.toString() == userLogged._id.toString()) { talk.isDeleteable = true; talk.isUpdatable = true; } else if (talk.event.owner == userLogged._id.toString()) { diff --git a/views/talk-detail.jade b/views/talk-detail.jade index d7dbcd0..20a659a 100644 --- a/views/talk-detail.jade +++ b/views/talk-detail.jade @@ -12,3 +12,9 @@ block content div.form-group label.detail-label.col-sm-2 Event p.col-sm-10= talk.event.name + div.form-group + label.detail-label.col-sm-2 Owner name + p.col-sm-10= talk.owner.name + div.form-group + label.detail-label.col-sm-2 Owner e-mail + p.col-sm-10= talk.owner.email diff --git a/views/talk-edit.jade b/views/talk-edit.jade index 3b72a1a..d067681 100644 --- a/views/talk-edit.jade +++ b/views/talk-edit.jade @@ -15,6 +15,12 @@ block content div.form-group label.detail-label.col-sm-2 Event p.col-sm-10= talk.event.name + div.form-group + label.detail-label.col-sm-2 Owner name + p.col-sm-10= talk.owner.name + div.form-group + label.detail-label.col-sm-2 Owner e-mail + p.col-sm-10= talk.owner.email input(type='hidden', name='talkEvent', value=talk.event.id) input(type='hidden', value=talk.id, name='talkId') button(type='submit', class='btn btn-primary pull-right') Salvar palestra!