Commit 54299bdf by Fernando Martínez Santiago Committed by root

issue #799, #804

parent 3d548583
/**
* Try.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName : 'try',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
autoIncrement: true,
primaryKey: true,
unique: true
},
workingSession: { // FK de WorkingSession. 1 a N
columnName: "id_ws",
model: "WorkingSession"
},
actions: {
collection: 'Action',
via: '_try'
},
begin: {
type: "datetime"
},
end: {
type: "datetime"
},
result: {
type: "string",
enum: ['SUCCESS','SUPERVISED SUCCESS','SPONTANEOUS SUCCESS','FAIL', 'DISCARDED', 'MODEL', 'BROKEN']
},
description: {
type: "string",
size: 1024
}
}
/**
* Try.js
*
* @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models
*/
module.exports = {
tableName : 'try',
migrate : 'safe',
schema : true,
autoPK : false,
autoCreatedAt : false,
autoUpdatedAt : false,
attributes: {
id: {
type: "integer",
autoIncrement: true,
primaryKey: true,
unique: true
},
workingSession: { // FK de WorkingSession. 1 a N
columnName: "id_ws",
model: "WorkingSession"
},
actions: {
collection: 'Action',
via: '_try'
},
begin: {
type: "datetime"
},
end: {
type: "datetime"
},
result: {
type: "string",
enum: ['SUCCESS','SUPERVISED SUCCESS','SPONTANEOUS SUCCESS','FAIL', 'DISCARDED', 'MODEL', 'BROKEN']
},
description: {
type: "string",
size: 1024
}
},
afterUpdate: function (attrs, next) {
StuOpenTry.findOne({id_ws: attrs.workingSession}).exec(function(err, stuopentry) {
if (err)
throw new Error("Error at"+attrs.workingSession+"("+err+")");
if (stuopentry)
attrs.next_try_id=stuopentry.openTry;
next();
});
}
}
\ No newline at end of file
......@@ -79,7 +79,15 @@ module.exports = {
next(err);
})
},
afterCreate: function (attrs, next) {
StuOpenTry.findOne({id_ws: attrs.id}).exec(function(err, stuopentry) {
if (err || !stuopentry)
throw new Error("No try found at"+attrs.id+"("+err+")");
attrs.first_try_id=stuopentry.openTry;
next();
});
},
//
// Returns the number of working sessions per year (REPORTS)
......
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