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
d36e04ff
authored
Jun 08, 2016
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Comments added to database tables and appropriate REFERENCE statements in foreign key fields
parent
5f9e03f7
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
99 additions
and
20 deletions
sails/bootstrap.sh
sails/playbook.yml
sails/roles/database/files/init-ignoresymbolstix.sql
sails/roles/database/files/pictodb-schema.sql
sails/roles/database/files/triggers-enrolments-integrity-constraints.sql
sails/roles/database/files/triggers-sessions-integrity-constraints.sql
sails/src/test/api/stu-spec.js
sails/src/test/api/sup-spec.js
sails/bootstrap.sh
View file @
d36e04ff
...
...
@@ -2,11 +2,11 @@
echo
"-- Running pictogram server"
if
[
-e
"src/app.js"
]
;
then
cd
src
&&
npm start
cd
src
&&
forever start app.js
--debug
elif
[
-e
"/vagrant/src/app.js"
]
;
then
cd
/vagrant/src
&&
npm start
cd
/vagrant/src
&&
forever start app.js
--debug
elif
[
-e
"/home/vagrant/sync/src/app.js"
]
;
then
cd
/home/vagrant/sync/src
&&
npm start
cd
/home/vagrant/sync/src
&&
forever start app.js
--debug
else
echo
"-- app.js not found, cannot run pictogram server"
exit
...
...
sails/playbook.yml
View file @
d36e04ff
...
...
@@ -6,3 +6,4 @@
roles
:
-
webapp
-
server
sails/roles/database/files/init-ignoresymbolstix.sql
0 → 100644
View file @
d36e04ff
SET
foreign_key_checks
=
0
;
GRANT
USAGE
ON
*
.
*
TO
'pictodbuser'
@
'localhost'
;
DROP
USER
'pictodbuser'
@
'localhost'
;
CREATE
USER
'pictodbuser'
@
'localhost'
identified
by
'p1KT015'
;
DROP
DATABASE
IF
EXISTS
pictodb
;
CREATE
DATABASE
pictodb
;
SET
foreign_key_checks
=
1
;
grant
all
privileges
on
pictodb
.
*
to
pictodbuser
;
flush
privileges
;
sails/roles/database/files/pictodb-schema.sql
View file @
d36e04ff
...
...
@@ -41,7 +41,8 @@ CREATE TABLE IF NOT EXISTS `action` (
KEY
`fk_sup_act`
(
`id_sup`
),
KEY
`fk_stu_act`
(
`id_stu`
),
KEY
`id_try`
(
`id_try`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COLLATE
=
utf8_unicode_ci
AUTO_INCREMENT
=
1
;
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COLLATE
=
utf8_unicode_ci
AUTO_INCREMENT
=
1
COMMENT
=
"This table registers and action performed by a user at a given time, all information of the action is in JSON format in the 'description' column and the operation performed is one of the possible for the 'type' column"
;
-- --------------------------------------------------------
...
...
sails/roles/database/files/triggers-enrolments-integrity-constraints.sql
View file @
d36e04ff
...
...
@@ -8,7 +8,14 @@ DELIMITER ;;
CREATE
TRIGGER
TRG_NEW_STUDENT_MAXENROLMENTS
BEFORE
INSERT
ON
student
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_BEFORE_INSERT_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
DECLARE
max_enr
,
curr_enr
INT
;
IF
new
.
id_off
IS
NOT
NULL
THEN
SELECT
...
...
@@ -30,7 +37,13 @@ END;;
CREATE
TRIGGER
TRG_NEW_STUDENT_UPDATE_ENROLMENTS
AFTER
INSERT
ON
student
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_AFTER_INSERT_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
UPDATE
office
...
...
@@ -44,7 +57,14 @@ END;;
CREATE
TRIGGER
TRG_MODIFY_STUDENT_ENROLMENTS
AFTER
UPDATE
ON
student
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_AFTER_UPDATE_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
IF
NOT
(
old
.
id_off
<=>
new
.
id_off
)
THEN
IF
(
old
.
id_off
IS
NOT
NULL
)
THEN
UPDATE
...
...
@@ -75,7 +95,14 @@ END;;
CREATE
TRIGGER
TRG_DELETE_STUDENT_ENROLMENTS
AFTER
DELETE
ON
student
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_AFTER_DELETE_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
IF
old
.
id_off
IS
NULL
THEN
UPDATE
office
...
...
sails/roles/database/files/triggers-sessions-integrity-constraints.sql
View file @
d36e04ff
...
...
@@ -95,7 +95,13 @@ END;;
CREATE
TRIGGER
TRG_SESSION_NEW
AFTER
INSERT
ON
working_session
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_AFTER_INSERT_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
DECLARE
idstu
INT
;
SELECT
DISTINCT
M
.
id_stu
INTO
idstu
...
...
@@ -121,7 +127,14 @@ END;;
CREATE
TRIGGER
TRG_SESSION_CLOSED
AFTER
UPDATE
ON
working_session
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_AFTER_UPDATE_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
IF
((
old
.
end
IS
NULL
)
and
(
new
.
end
IS
NOT
NULL
))
THEN
CALL
deleteOpenTry
(
new
.
id
);
END
IF
;
...
...
@@ -134,7 +147,13 @@ END;;
CREATE
TRIGGER
TRG_NEW_EVENT_ONSESSION
BEFORE
INSERT
ON
action
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_BEFORE_INSERT_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
DECLARE
idstu
INT
;
DECLARE
idtry
INT
;
SET
idstu
=
NEW
.
id_stu
;
...
...
@@ -158,7 +177,14 @@ END;;
CREATE
TRIGGER
TRG_NEW_EVENT
AFTER
INSERT
ON
action
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_AFTER_INSERT_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
DECLARE
idopentry
INT
;
DECLARE
idsup_ws
INT
;
DECLARE
idws
INT
;
...
...
@@ -207,7 +233,14 @@ ALTER TABLE `working_session`
CREATE
TRIGGER
TRG_SESSION_CLOSING
BEFORE
UPDATE
ON
working_session
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_BEFORE_UPDATE_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
IF
((
new
.
end
IS
NOT
NULL
)
AND
(
new
.
current
IS
NOT
NULL
))
THEN
SET
new
.
current
=
NULL
;
END
IF
;
...
...
@@ -225,7 +258,13 @@ ALTER TABLE `action`
CREATE
TRIGGER
TRG_TRY_EVALUATED
AFTER
UPDATE
ON
try
FOR
EACH
ROW
BEGIN
thisTrigger
:
BEGIN
IF
((
@
TRIGGER_CHECKS
=
FALSE
)
OR
(
@
TRIGGER_AFTER_UPDATE_CHECKS
=
FALSE
))
AND
(
USER
()
=
'root@localhost'
)
THEN
LEAVE
thisTrigger
;
END
IF
;
DECLARE
idopentry
INT
;
DECLARE
idws
INT
;
DECLARE
ws_end
DATE
;
...
...
@@ -243,6 +282,3 @@ END;;
DELIMITER
;
sails/src/test/api/stu-spec.js
View file @
d36e04ff
...
...
@@ -9,13 +9,17 @@ describe('Student API', function () {
delete
studentAgentData
.
password
;
studentAgentData
.
current_method
=
'Test Method'
;
studentAgentData
.
current_instruction
=
'Test Instruction'
;
supervisorAgent
.
get
(
'/stu/'
+
studentAgent
.
data
.
id
)
.
send
()
.
expect
(
200
)
.
expect
(
studentAgentData
)
.
end
(
done
);
.
end
((
error
)
=>
{
if
(
error
)
{
throw
error
;
};
done
();
});
});
it
(
'GET /stu/:id_stu/supervisors'
,
function
(
done
)
{
supervisorAgent
...
...
sails/src/test/api/sup-spec.js
View file @
d36e04ff
...
...
@@ -66,11 +66,12 @@ describe('Supervisor API', function () {
})
.
end
(
done
);
});
it
(
'GET /sup/:id/pic_fromcategory/:id_cat'
,
function
(
done
)
{
it
.
only
(
'GET /sup/:id/pic_fromcategory/:id_cat'
,
function
(
done
)
{
supervisorAgent
.
get
(
'/sup/'
+
supervisorAgent
.
data
.
id
+
'/pic_fromcategory/41'
).
send
()
.
expect
(
200
)
.
expect
(
function
(
response
)
{
assert
.
isArray
(
response
.
body
);
assert
.
isAtLeast
(
response
.
body
.
length
,
1
,
'category 41 is empty'
);
response
.
body
.
forEach
(
function
(
picto
)
{
assert
.
isObject
(
picto
);
assert
.
isNumber
(
picto
.
source
);
...
...
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