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
3f45eb3e
authored
Sep 08, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
solved issue with supervisor linking
parent
dfef2f37
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
8 deletions
sails/src/api/controllers/SupervisorController.js
sails/src/api/controllers/SupervisorController.js
View file @
3f45eb3e
...
@@ -551,18 +551,20 @@ module.exports = {
...
@@ -551,18 +551,20 @@ module.exports = {
*
*
*/
*/
link_supervisor
:
function
(
req
,
res
)
{
link_supervisor
:
function
(
req
,
res
)
{
if
(
!
req
.
params
.
id_off
||
!
req
.
params
.
id_sup
)
var
params
=
req
.
allParams
();
if
(
!
params
.
id_off
||
!
params
.
id_sup
)
return
res
.
badRequest
();
return
res
.
badRequest
();
if
(
req
.
params
.
id_off
==
req
.
params
.
id_sup
)
if
(
params
.
id_off
==
params
.
id_sup
)
return
res
.
badRequest
(
"Link to yourself is not allowed"
);
return
res
.
badRequest
(
"Link to yourself is not allowed"
);
// Check that both ids are valid
// Check that both ids are valid
Supervisor
.
findOne
(
req
.
params
.
id_sup
)
Supervisor
.
findOne
(
params
.
id_sup
)
.
then
((
sup
)
=>
{
.
then
((
sup
)
=>
{
if
(
!
sup
)
if
(
!
sup
)
throw
new
Error
(
"Supervisor not found"
);
throw
new
Error
(
"Supervisor not found"
);
return
[
sup
,
Supervisor
.
findOne
(
req
.
params
.
id_off
)];
return
[
sup
,
Supervisor
.
findOne
(
params
.
id_off
)];
})
})
.
spread
((
sup
,
off
)
=>
{
.
spread
((
sup
,
off
)
=>
{
if
(
!
off
)
if
(
!
off
)
...
@@ -601,20 +603,22 @@ module.exports = {
...
@@ -601,20 +603,22 @@ module.exports = {
*
*
*/
*/
unlink_supervisor
:
function
(
req
,
res
)
{
unlink_supervisor
:
function
(
req
,
res
)
{
if
(
!
req
.
params
.
id_off
||
!
req
.
params
.
id_sup
)
var
params
=
req
.
allParams
();
if
(
!
params
.
id_off
||
!
params
.
id_sup
)
return
res
.
badRequest
();
return
res
.
badRequest
();
// Check that both ids are valid
// Check that both ids are valid
Supervisor
.
findOne
(
req
.
params
.
id_sup
)
Supervisor
.
findOne
(
params
.
id_sup
)
.
then
((
s
)
=>
{
.
then
((
s
)
=>
{
if
(
!
s
)
if
(
!
s
)
throw
new
Error
(
"Supervisor not found"
);
throw
new
Error
(
"Supervisor not found"
);
return
Supervisor
.
findOne
(
req
.
params
.
id_off
);
return
Supervisor
.
findOne
(
params
.
id_off
);
})
})
.
then
((
s
)
=>
{
.
then
((
s
)
=>
{
if
(
!
s
)
if
(
!
s
)
throw
new
Error
(
"Supervisor not found"
);
throw
new
Error
(
"Supervisor not found"
);
return
SupOff
.
destroy
({
supervisor
:
req
.
params
.
id_sup
,
office
:
req
.
params
.
id_off
});
return
SupOff
.
destroy
({
supervisor
:
params
.
id_sup
,
office
:
params
.
id_off
});
})
})
.
then
((
sos
)
=>
{
.
then
((
sos
)
=>
{
if
(
!
sos
)
if
(
!
sos
)
...
...
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