Customize the item for the applications list.

Thanks to https://github.com/stenington/CSOL-site/compare/my-applications
This commit is contained in:
Ian Dees 2013-06-02 23:28:19 +00:00
Родитель b0715d5e87
Коммит 0aa6352489
2 изменённых файлов: 33 добавлений и 5 удалений

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

@ -1,6 +1,8 @@
const _ = require('underscore');
const openbadger = require('../openbadger');
const db = require('../db');
const claim = db.model('Claim');
const applications = db.model('Application');
const loggedIn = require('../middleware').loggedIn;
module.exports = function (app) {
@ -94,12 +96,20 @@ module.exports = function (app) {
app.get('/myapplications', [
loggedIn,
openbadger.middleware('getUserBadge')
openbadger.middleware('getUserBadges')
], function (req, res, next) {
var data = req.remote;
res.render('user/applications.html', {
items: data.badges
var user = req.session.user;
applications.findAll({where: {LearnerId: user.id}}).success(function (applications) {
var badgenames = _.map(applications, function(app) { return app.badgeId; });
openbadger.getUserBadges(user.id, function (err, data) {
var appliedFor = _.map(data.badges, function(badge) { return badgenames.indexOf(badge.id) !== -1; });
res.render('user/applications.html', {
items: _.map(appliedFor, function(badge) {
badge.url = '/myapplications/foo' + badge.id;
return badge;
})
});
});
});
});

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

@ -2,6 +2,24 @@
{% set pageTitle = 'My Applications' %}
{% set navItem = 'backpack' %}
{% block item %}
<li class="span3">
<figure class="thumbnail">
<a href="{{ item.url }}"><img src="{{ item.image }}"></a>
<figcaption class="caption">
<p>{{ item.name }}</p>
{% block item_actions_wrapper %}
<p class="text-right">
{% block item_actions %}
<a href="{{ item.url }}" class="btn">Details</a>
{% endblock %}
</p>
{% endblock %}
</figcaption>
</figure>
</li>
{% endblock %}
{% block list %}
{{ super() }}
<li class="span3">