Commit e8155468 by Jose Antonio

Added arasaac license to supervisor model

parent 83d61be6
...@@ -372,6 +372,8 @@ CREATE TABLE IF NOT EXISTS `supervisor` ( ...@@ -372,6 +372,8 @@ CREATE TABLE IF NOT EXISTS `supervisor` (
`password` varchar(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Encrypted password using the BCrypt algorithm', `password` varchar(60) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL COMMENT 'Encrypted password using the BCrypt algorithm',
`id_off` int(11) DEFAULT NULL, `id_off` int(11) DEFAULT NULL,
`active` boolean DEFAULT FALSE, `active` boolean DEFAULT FALSE,
`arasaac_license` boolean DEFAULT FALSE,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `email` (`email`), UNIQUE KEY `email` (`email`),
KEY `id_off` (`id_off`) KEY `id_off` (`id_off`)
......
...@@ -13,6 +13,11 @@ Changes to be performed manually in servers to upgrade ...@@ -13,6 +13,11 @@ Changes to be performed manually in servers to upgrade
## Database ## Database
(ToDo in dev)
- alter table supervisor add arasaac license:
`ALTER TABLE supervisor ADD COLUMN arasaac_license BOOLEAN DEFAULT FALSE;`
(already done in dev) (already done in dev)
- load pictocat_tree_populate.sql - load pictocat_tree_populate.sql
......
...@@ -200,6 +200,31 @@ module.exports = { ...@@ -200,6 +200,31 @@ module.exports = {
}, },
/** /**
* Acept Arasaac License
* @param {request} req
* {
* "token": "12398123aas78sf798as7d987234" // Encryted code with supervisor ID, siging role and id_off
* }
*/
accept_arasaac: function (req, res) {
var params = req.params.all();
Supervisor.findOne(params.id)
.then(function (supervisor) {
if (!supervisor)
throw new Error("Error when looking for user");
supervisor.arasaacLicense = true;
supervisor.save();
res.ok();
})
.catch(function (err) {
return res.serverError(err.message ? err.message : 'Supervisor not found');
});
},
/**
* Gets a supervisor by his email * Gets a supervisor by his email
* @param {request} req {} (width email as url parameter) * @param {request} req {} (width email as url parameter)
* @param {response} res * @param {response} res
...@@ -261,7 +286,7 @@ module.exports = { ...@@ -261,7 +286,7 @@ module.exports = {
create: function (req, res) { create: function (req, res) {
var params = req.params.all(); var params = req.params.all();
var supervisor; var supervisor;
// Send email confirmation // Send email confirmation
function sendConfirmationMail(cb) { function sendConfirmationMail(cb) {
...@@ -318,7 +343,7 @@ module.exports = { ...@@ -318,7 +343,7 @@ module.exports = {
return res.serverError("Supervisor created but returned null"); return res.serverError("Supervisor created but returned null");
supervisor = sup; supervisor = sup;
if (params.role === 'therapist_office' || params.role === 'tutor_office') { if (params.role === 'therapist_office' || params.role === 'tutor_office') {
sendConfirmationMail((err) => { sendConfirmationMail((err) => {
if (err) throw err; if (err) throw err;
......
...@@ -84,6 +84,10 @@ module.exports = { ...@@ -84,6 +84,10 @@ module.exports = {
active: { active: {
type: 'boolean' type: 'boolean'
}, },
arasaacLicense: {
type: 'boolean',
columnName: 'arasaac_license'
},
office: { office: {
columnName: 'id_off', columnName: 'id_off',
type: 'integer', type: 'integer',
......
...@@ -134,6 +134,7 @@ module.exports.policies = { ...@@ -134,6 +134,7 @@ module.exports.policies = {
change_password: true, change_password: true,
request_change_password: true, request_change_password: true,
activate: true, activate: true,
accept_arasaac: ['tokenAuth'],
upload: ['tokenAuth'], upload: ['tokenAuth'],
subscribe: ['tokenAuth'], subscribe: ['tokenAuth'],
unsubscribe: ['tokenAuth'], unsubscribe: ['tokenAuth'],
......
...@@ -107,10 +107,12 @@ module.exports.routes = { ...@@ -107,10 +107,12 @@ module.exports.routes = {
'GET /sup/:id/pic_categories/:id_cat': 'PictoController.categories', 'GET /sup/:id/pic_categories/:id_cat': 'PictoController.categories',
'GET /sup/:id/pic_fromcategory/:id_cat': 'PictoController.fromcategory', 'GET /sup/:id/pic_fromcategory/:id_cat': 'PictoController.fromcategory',
'GET /sup/:id/pic_fromSymbolStx/page/:page/limit/:limit': 'PictoController.fromSymbolStx', 'GET /sup/:id/pic_fromSymbolStx/page/:page/limit/:limit': 'PictoController.fromSymbolStx',
'GET /sup/:id/pic_fromArasaac/page/:page/limit/:limit': 'PictoController.fromArasaac',
'GET /sup/:id/pic_fromCatSubcat/category/:id_cat/page/:page/limit/:limit': 'PictoController.fromCatSubcat', 'GET /sup/:id/pic_fromCatSubcat/category/:id_cat/page/:page/limit/:limit': 'PictoController.fromCatSubcat',
'GET /sup/:id/pic_fromSearch/:text/category/:id_cat/source/:source': 'PictoController.fromSearch', 'GET /sup/:id/pic_fromSearch/:text/category/:id_cat/source/:source': 'PictoController.fromSearch',
'GET /sup/email/:email': 'SupervisorController.getByEmail', 'GET /sup/email/:email': 'SupervisorController.getByEmail',
'GET /sup/changepass/:email': 'SupervisorController.request_change_password', 'GET /sup/changepass/:email': 'SupervisorController.request_change_password',
'GET /sup/arasaac_license/:id': 'SupervisorController.accept_arasaac',
'PUT /sup/changepass': 'SupervisorController.change_password', 'PUT /sup/changepass': 'SupervisorController.change_password',
'PUT /sup/:id': 'SupervisorController.update', 'PUT /sup/:id': 'SupervisorController.update',
'POST /sup': 'SupervisorController.create', 'POST /sup': 'SupervisorController.create',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment