Browse Source

on join and unjoin, return all travels

master
idoctnef 8 years ago
parent
commit
b925f446b9
3 changed files with 24 additions and 7 deletions
  1. +3
    -0
      README.md
  2. +4
    -4
      config.js
  3. +17
    -3
      controllers/travelController.js

+ 3
- 0
README.md

@ -39,6 +39,9 @@ frontend app code: https://github.com/idoctnef/collectivecarApp
-comment publication(car, travel, package) --> done -comment publication(car, travel, package) --> done
-valorating users system -valorating users system
-passed dates not shown from server
-don't allow to add travels with passed date
-GUI admin page -GUI admin page
-UX design -UX design

+ 4
- 4
config.js

@ -1,8 +1,8 @@
module.exports = { module.exports = {
/*'secret': process.env.SECRET,// production version
'database': process.env.MONGO_DSN,*/
'secret': 'secretfortoken',// local version
'database': 'mongodb://localhost/comunalcar',
'secret': process.env.SECRET,// production version
'database': process.env.MONGO_DSN,
/*'secret': 'secretfortoken',// local version
'database': 'mongodb://localhost/comunalcar',*/
"port" : process.env.PORT || 3000 "port" : process.env.PORT || 3000
}; };

+ 17
- 3
controllers/travelController.js

@ -71,8 +71,14 @@ exports.addTravel = function(req, res) {
travel.save(function(err, travel) { travel.save(function(err, travel) {
if(err) return res.send(500, err.message); if(err) return res.send(500, err.message);
res.status(200).jsonp(travel);
//res.status(200).jsonp(travel);
travelModel.find(function(err, travels) {
if(err) res.send(500, err.message);
res.status(200).jsonp(travels);
});
}); });
}; };
//PUT //PUT
@ -119,7 +125,11 @@ exports.addJoin = function(req, res) {
travel.save(function(err, travel) { travel.save(function(err, travel) {
if(err) return res.send(500, err.message); if(err) return res.send(500, err.message);
res.status(200).jsonp(travel);
//res.status(200).jsonp(travel);
travelModel.find(function(err, travels) {
if(err) res.send(500, err.message);
res.status(200).jsonp(travels);
});
}); });
}); });
}; };
@ -152,7 +162,11 @@ exports.doUnjoin = function(req, res) {
travel.save(function(err, travel) { travel.save(function(err, travel) {
if(err) return res.send(500, err.message); if(err) return res.send(500, err.message);
res.status(200).jsonp(travel);
//res.status(200).jsonp(travel);
travelModel.find(function(err, travels) {
if(err) res.send(500, err.message);
res.status(200).jsonp(travels);
});
}); });
}); });
}; };

Loading…
Cancel
Save