Skip to content

Commit

Permalink
added vacations index
Browse files Browse the repository at this point in the history
  • Loading branch information
abarnhard committed Aug 19, 2014
1 parent 521bdc9 commit 5a3e725
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
15 changes: 13 additions & 2 deletions app/controllers/vacations.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
'use strict';

var Vacation = require('../models/vacation');

exports.init = function(req, res){
res.render('vacations/init');
};


exports.create = function(req, res){
console.log(req.body);
// console.log(req.body);
Vacation.save(req.body, function(){
res.redirect('/vacations');
});
};

exports.index = function(req, res){
Vacation.all(function(err, vacations){
// console.log(vacations);
res.render('vacations/index', {vacations:vacations});
});
};

6 changes: 5 additions & 1 deletion app/models/vacation.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,8 @@ Vacation.save = function(o, cb){
};

module.exports = Vacation;

/* Will need later:
Vacation.collection.update({_id:id}, {$set:{balance:a.balance}, $inc:{numTransacts:1}, $push:{transactions:t}}, function(){
if(cb){cb();}
});
*/
1 change: 1 addition & 0 deletions app/routes/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ module.exports = function(app, express){

app.get('/vacations/new', vacations.init);
app.post('/vacations', vacations.create);
app.get('/vacations', vacations.index);

console.log('Routes Loaded');
};
Expand Down
1 change: 1 addition & 0 deletions app/views/shared/nav.jade
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ nav.navbar.navbar-default(role='navigation')
li: a(href='/about') About
li: a(href='/faq') FAQ
li: a(href='/contact') Contact
li: a(href='/vacations') View Vacations
li: a(href='/vacations/new') Add Vacation

Empty file added app/views/vacations/index.jade
Empty file.

0 comments on commit 5a3e725

Please sign in to comment.