Browse Source

unjoin implemented

pull/2/head
idoctnef 8 years ago
parent
commit
1d924c3082
3 changed files with 28 additions and 6 deletions
  1. +6
    -6
      README.md
  2. +19
    -0
      controllers/travelController.js
  3. +3
    -0
      server.js

+ 6
- 6
README.md

@ -22,19 +22,19 @@ frontend app code: https://github.com/idoctnef/collectivecarApp
-delete travel --> done -delete travel --> done
-create offeringCar --> done -create offeringCar --> done
-update offeringCar -update offeringCar
-delete offeringCar
-delete offeringCar --> done
-create askingForTravel (needtravel) --> done -create askingForTravel (needtravel) --> done
-update askingForTravel -update askingForTravel
-delete askgingForTravel
-delete askgingForTravel --> done
-create askingPackage (need transport package) --> done -create askingPackage (need transport package) --> done
-update askingPackage -update askingPackage
-delete askgingPackage
-delete askgingPackage --> done
-user joins a car --> done -user joins a car --> done
-user offer car to a travel --> done -user offer car to a travel --> done
-user offer car to a askingpackage --> done -user offer car to a askingpackage --> done
-user unjoins a car
-user unoffer car to a travel
-user unoffer car to a askingpackage
-user unjoins a car --> done
-user unoffer car to a travel --> done
-user unoffer car to a askingpackage --> done
-comment publication(car, travel, package) --> done -comment publication(car, travel, package) --> done
-valorating users system -valorating users system

+ 19
- 0
controllers/travelController.js

@ -121,6 +121,25 @@ exports.addJoin = function(req, res) {
}); });
}; };
exports.doUnjoin = function(req, res) {
joinModel.find({
travelId: req.params.travelId
}, function(err, joins) {
for(var i=0; i<joins.length; i++)
{
if(joins[i].joinedUsername==req.body.joinedUsername)
{
joins[i].remove(function(err) {
if(err) return res.send(500, err.message);
res.status(200).jsonp('removed');
console.log('DELETE /unjoin/' + req.params.id);
})
}
}
});
};
exports.getJoinsByTravelId = function(req, res) { exports.getJoinsByTravelId = function(req, res) {
joinModel.find({ joinModel.find({
travelId: req.params.travelId travelId: req.params.travelId

+ 3
- 0
server.js

@ -124,6 +124,9 @@ apiRoutes.route('/travels/:id')
apiRoutes.route('/travels/join/:travelId') apiRoutes.route('/travels/join/:travelId')
.post(travelCtrl.addJoin); .post(travelCtrl.addJoin);
apiRoutes.route('/travels/unjoin/:travelId')
.post(travelCtrl.doUnjoin);
apiRoutes.route('/travels/comment/:travelId') apiRoutes.route('/travels/comment/:travelId')
.post(travelCtrl.addComment); .post(travelCtrl.addComment);

Loading…
Cancel
Save