Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
yotta
/
pictogram
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
60
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
54299bdf
authored
Jan 15, 2017
by
Fernando Martínez Santiago
Committed by
root
Jan 15, 2017
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
issue #799, #804
parent
3d548583
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
46 deletions
sails/src/api/models/Try.js
sails/src/api/models/WorkingSession.js
sails/src/api/models/Try.js
View file @
54299bdf
/**
/**
* 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
sails/src/api/models/WorkingSession.js
View file @
54299bdf
...
@@ -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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment