mirror of
https://github.com/bodyrep/DemoApp.git
synced 2026-02-01 18:11:36 +00:00
can read and display workouts
This commit is contained in:
@@ -1,10 +1,9 @@
|
||||
var workout = require('../../data/models/workout');
|
||||
|
||||
function loadworkout(req, res, next) {
|
||||
console.log('fetch id' + req.params.title );
|
||||
workout.findOne({title: req.params.title})
|
||||
.populate('elements')
|
||||
|
||||
console.log('fetch id' + req.params._id );
|
||||
workout.findOne({_id: req.params._id})
|
||||
//.populate('elements')
|
||||
.exec(function(err, workout) {
|
||||
if (err) {
|
||||
return next(err);
|
||||
@@ -13,6 +12,11 @@ function loadworkout(req, res, next) {
|
||||
return res.send('Not found', 404);
|
||||
}
|
||||
console.log('workout' + JSON.stringify(workout));
|
||||
workout.elements.forEach(function(element, index, array) {
|
||||
// console.log("elementID" + element._id);
|
||||
// console.log("elementID" + JSON.stringify(element.splits));
|
||||
});
|
||||
|
||||
req.workout = workout;
|
||||
next();
|
||||
});
|
||||
|
||||
@@ -3,7 +3,7 @@ function loggedIn(req, res, next) {
|
||||
console.log("not logged in - redirecting to login");
|
||||
res.redirect('/session/new');
|
||||
} else {
|
||||
console.log("user logged in");
|
||||
console.log("user logged in" + JSON.stringify(req.session.user));
|
||||
next();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user