зеркало из https://github.com/mozilla/CSOL-site.git
Extending learner model functionality
This commit is contained in:
Родитель
e30ec86128
Коммит
b258364975
|
@ -1,6 +1,10 @@
|
|||
var db = require('../db');
|
||||
var applications;
|
||||
|
||||
module.exports = {
|
||||
setup: function () {
|
||||
applications = db.model('Application');
|
||||
},
|
||||
properties: {
|
||||
id: {
|
||||
type: db.type.INTEGER,
|
||||
|
@ -47,5 +51,22 @@ module.exports = {
|
|||
model: 'Application',
|
||||
type: 'hasMany'
|
||||
}
|
||||
]
|
||||
],
|
||||
instanceMethods: {
|
||||
getBadgeApplicationState: function (badgeId, callback) {
|
||||
if (badgeId.id)
|
||||
badgeId = badgeId.id;
|
||||
|
||||
applications.find({where: {LearnerId: this.id, badgeId: badgeId}})
|
||||
.complete(function (err, application) {
|
||||
if (err)
|
||||
return callback(err);
|
||||
|
||||
if (!application)
|
||||
return callback(null);
|
||||
|
||||
callback(null, application.state);
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче