add task export functionality
This commit is contained in:
@@ -22,6 +22,48 @@ var request = require('request');
|
||||
------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
function buildTaskList(list) {
|
||||
var output = [];
|
||||
_.each(list, function(task) {
|
||||
output.push(task);
|
||||
});
|
||||
return output;
|
||||
}
|
||||
|
||||
dataexport.habits = function(req, res) {
|
||||
return res.jsonstring({
|
||||
'habits': buildTaskList(res.locals.user.habits)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.dailies = function(req, res) {
|
||||
return res.jsonstring({
|
||||
'dailies': buildTaskList(res.locals.user.dailys)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.todos = function(req, res) {
|
||||
return res.jsonstring({
|
||||
'todos': buildTaskList(res.locals.user.todos)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.rewards = function(req, res) {
|
||||
return res.jsonstring({
|
||||
'rewards': buildTaskList(res.locals.user.rewards)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.tasks = function(req, res) {
|
||||
var user = res.locals.user;
|
||||
return res.jsonstring({
|
||||
'habits': buildTaskList(user.habits),
|
||||
'dailies': buildTaskList(user.dailys),
|
||||
'todos': buildTaskList(user.todos),
|
||||
'rewards': buildTaskList(user.rewards)
|
||||
});
|
||||
}
|
||||
|
||||
dataexport.history = function(req, res) {
|
||||
var user = res.locals.user;
|
||||
var output = [
|
||||
|
||||
@@ -7,6 +7,11 @@ var i18n = require('../i18n');
|
||||
var middleware = require('../middleware.js');
|
||||
|
||||
/* Data export */
|
||||
router.get('/habits.json',auth.authWithSession,i18n.getUserLanguage,dataexport.habits); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/dailies.json',auth.authWithSession,i18n.getUserLanguage,dataexport.dailies); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/todos.json',auth.authWithSession,i18n.getUserLanguage,dataexport.todos); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/tasks.json',auth.authWithSession,i18n.getUserLanguage,dataexport.tasks); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/rewards.json',auth.authWithSession,i18n.getUserLanguage,dataexport.rewards); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/history.csv',auth.authWithSession,i18n.getUserLanguage,dataexport.history); //[todo] encode data output options in the data controller and use these to build routes
|
||||
router.get('/userdata.xml',auth.authWithSession,i18n.getUserLanguage,dataexport.leanuser,dataexport.userdata.xml);
|
||||
router.get('/userdata.json',auth.authWithSession,i18n.getUserLanguage,dataexport.leanuser,dataexport.userdata.json);
|
||||
|
||||
Reference in New Issue
Block a user