Add a /myapplications/:id endpoint.

This commit is contained in:
Ian Dees 2013-06-04 02:58:16 +00:00
Родитель 360232bab7
Коммит b82af27e78
1 изменённых файлов: 12 добавлений и 3 удалений

Просмотреть файл

@ -128,8 +128,7 @@ module.exports = function (app) {
});
app.get('/myapplications', [
loggedIn,
openbadger.middleware('getUserBadges')
loggedIn
], function (req, res, next) {
var user = req.session.user;
applications.findAll({where: {LearnerId: user.id}}).success(function (applications) {
@ -137,7 +136,6 @@ module.exports = function (app) {
_.each(applications, function(app) {
_.extend(app, _.findWhere(data.badges, {id: app.badgeId}));
});
console.log(applications);
res.render('user/applications.html', {
items: _.map(applications, function(badge) {
badge.url = '/myapplications/' + badge.id;
@ -147,6 +145,17 @@ module.exports = function (app) {
});
});
});
app.get('/myapplications/:id', [
loggedIn
], function (req, res, next) {
var user = req.session.user;
applications.find({where: {LearnerId: user.id, BadgeId: req.params.id}}).success(function (application) {
res.render('user/application.html', {
item: application
});
});
});
app.get('/favorites/:view?', function (req, res, next) {
var badge = {