From ce43c277e1e0003f1e9930e20ed097aa0704e546 Mon Sep 17 00:00:00 2001 From: Prateek Kumar Date: Thu, 19 Jan 2017 19:35:50 +0530 Subject: [PATCH] update team --- models/accommodations.js | 34 +++---- routes/index.js | 17 +++- templates/views/adminteam.html | 160 ++++++++++++++++++++++++++++++--- 3 files changed, 183 insertions(+), 28 deletions(-) diff --git a/models/accommodations.js b/models/accommodations.js index 32c6085..9f41f04 100644 --- a/models/accommodations.js +++ b/models/accommodations.js @@ -25,23 +25,27 @@ Accommodation.add({ }); Accommodation.schema.pre('save', function(next){ - if (!this.mailStatus && this.confirmed) { - User.model.findById(this.user).then((user)=>{ - this.mailStatus = true; - require('../routes/mail.js').sendAAMail(user.email, user.name.first+' '+user.name.last); + User.model.findById(this.user).then((user)=>{ + this.email = user.email; + this.phone = user.phone; + if (!this.mailStatus && this.confirmed) { + User.model.findById(this.user).then((user)=>{ + this.mailStatus = true; + require('../routes/mail.js').sendAAMail(user.email, user.name.first+' '+user.name.last); + next(); + }, (err)=>{ + console.log(err); + next(); + }); + } + else if (!this.confirmed) { + this.mailStatus = false; next(); - }, (err)=>{ - console.log(err); + } + else { next(); - }); - } - else if (!this.confirmed) { - this.mailStatus = false; - next(); - } - else { - next(); - } + } + }) }); Accommodation.defaultColumns = 'id|1%, user|15%, email|20%%, phone|15%, noOfMale|5%, noOfFemale|5%, on19|5%, on20|5%, on21|5%, on22|5%, confirmed, notes'; diff --git a/routes/index.js b/routes/index.js index a6a89f4..a134ba8 100644 --- a/routes/index.js +++ b/routes/index.js @@ -507,7 +507,22 @@ exports = module.exports = function (app) { if (!req.user || !req.user.canAccessKeystone) { return res.notfound(); } - res.render('adminteam'); + Event.model.find({}).then(evts=>{ + res.render('adminteam', {events: evts}); + }, err=>res.notfound()) + }) + + app.post('/admin/team', (req, res)=>{ + if (!req.user || !req.user.canAccessKeystone) { + return res.json({status: false}); + } + new Team.model({ + name: req.body.name, + event: req.body.event, + members: req.body.members + }).save().then(team=>{ + res.json({status: true, team: team}) + }, err=>{res.json({status: false})}); }) app.get('/admin/:event', function(req, res){ diff --git a/templates/views/adminteam.html b/templates/views/adminteam.html index d036e4f..4cfc71f 100644 --- a/templates/views/adminteam.html +++ b/templates/views/adminteam.html @@ -5,7 +5,6 @@ Dashboard - @@ -22,11 +21,47 @@
-

Team

-
- -

- +
+
+ + + + +
+
+ +
+
+ + +
+ + +

+
+
+
+ + + + + + + + + + + + + + + + +
@@ -36,14 +71,115 @@

Team