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

issue #799, #804

parent 3d548583
/** /**
* Try.js * Try.js
* *
* @description :: TODO: Write a short summary of how this model works and what it represents here. * @description :: TODO: Write a short summary of how this model works and what it represents here.
* @docs :: http://sailsjs.org/#!documentation/models * @docs :: http://sailsjs.org/#!documentation/models
*/ */
module.exports = { module.exports = {
tableName : 'try', tableName : 'try',
migrate : 'safe', migrate : 'safe',
schema : true, schema : true,
autoPK : false, autoPK : false,
autoCreatedAt : false, autoCreatedAt : false,
autoUpdatedAt : false, autoUpdatedAt : false,
attributes: { attributes: {
id: { id: {
type: "integer", type: "integer",
autoIncrement: true, autoIncrement: true,
primaryKey: true, primaryKey: true,
unique: true unique: true
}, },
workingSession: { // FK de WorkingSession. 1 a N workingSession: { // FK de WorkingSession. 1 a N
columnName: "id_ws", columnName: "id_ws",
model: "WorkingSession" model: "WorkingSession"
}, },
actions: { actions: {
collection: 'Action', collection: 'Action',
via: '_try' via: '_try'
}, },
begin: { begin: {
type: "datetime" type: "datetime"
}, },
end: { end: {
type: "datetime" type: "datetime"
}, },
result: { result: {
type: "string", type: "string",
enum: ['SUCCESS','SUPERVISED SUCCESS','SPONTANEOUS SUCCESS','FAIL', 'DISCARDED', 'MODEL', 'BROKEN'] enum: ['SUCCESS','SUPERVISED SUCCESS','SPONTANEOUS SUCCESS','FAIL', 'DISCARDED', 'MODEL', 'BROKEN']
}, },
description: { description: {
type: "string", type: "string",
size: 1024 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 = { ...@@ -79,7 +79,15 @@ module.exports = {
next(err); 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) // 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