Comments added to database tables and appropriate REFERENCE statements in foreign key fields

parent 5f9e03f7
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
echo "-- Running pictogram server" echo "-- Running pictogram server"
if [ -e "src/app.js" ]; then if [ -e "src/app.js" ]; then
cd src && npm start cd src && forever start app.js --debug
elif [ -e "/vagrant/src/app.js" ]; then 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 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 else
echo "-- app.js not found, cannot run pictogram server" echo "-- app.js not found, cannot run pictogram server"
exit exit
......
...@@ -6,3 +6,4 @@ ...@@ -6,3 +6,4 @@
roles: roles:
- webapp - webapp
- server - server
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;
...@@ -41,7 +41,8 @@ CREATE TABLE IF NOT EXISTS `action` ( ...@@ -41,7 +41,8 @@ CREATE TABLE IF NOT EXISTS `action` (
KEY `fk_sup_act` (`id_sup`), KEY `fk_sup_act` (`id_sup`),
KEY `fk_stu_act` (`id_stu`), KEY `fk_stu_act` (`id_stu`),
KEY `id_try` (`id_try`) 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";
-- -------------------------------------------------------- -- --------------------------------------------------------
......
...@@ -8,7 +8,14 @@ DELIMITER ;; ...@@ -8,7 +8,14 @@ DELIMITER ;;
CREATE TRIGGER TRG_NEW_STUDENT_MAXENROLMENTS CREATE TRIGGER TRG_NEW_STUDENT_MAXENROLMENTS
BEFORE INSERT ON student BEFORE INSERT ON student
FOR EACH ROW 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; DECLARE max_enr,curr_enr INT;
IF new.id_off IS NOT NULL THEN IF new.id_off IS NOT NULL THEN
SELECT SELECT
...@@ -30,7 +37,13 @@ END;; ...@@ -30,7 +37,13 @@ END;;
CREATE TRIGGER TRG_NEW_STUDENT_UPDATE_ENROLMENTS CREATE TRIGGER TRG_NEW_STUDENT_UPDATE_ENROLMENTS
AFTER INSERT ON student AFTER INSERT ON student
FOR EACH ROW 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 UPDATE
office office
...@@ -44,7 +57,14 @@ END;; ...@@ -44,7 +57,14 @@ END;;
CREATE TRIGGER TRG_MODIFY_STUDENT_ENROLMENTS CREATE TRIGGER TRG_MODIFY_STUDENT_ENROLMENTS
AFTER UPDATE ON student AFTER UPDATE ON student
FOR EACH ROW 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 NOT (old.id_off<=>new.id_off) THEN
IF (old.id_off IS NOT NULL) THEN IF (old.id_off IS NOT NULL) THEN
UPDATE UPDATE
...@@ -75,7 +95,14 @@ END;; ...@@ -75,7 +95,14 @@ END;;
CREATE TRIGGER TRG_DELETE_STUDENT_ENROLMENTS CREATE TRIGGER TRG_DELETE_STUDENT_ENROLMENTS
AFTER DELETE ON student AFTER DELETE ON student
FOR EACH ROW 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 IF old.id_off IS NULL THEN
UPDATE UPDATE
office office
......
...@@ -95,7 +95,13 @@ END;; ...@@ -95,7 +95,13 @@ END;;
CREATE TRIGGER TRG_SESSION_NEW CREATE TRIGGER TRG_SESSION_NEW
AFTER INSERT ON working_session AFTER INSERT ON working_session
FOR EACH ROW 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; DECLARE idstu INT;
SELECT DISTINCT M.id_stu INTO idstu SELECT DISTINCT M.id_stu INTO idstu
...@@ -121,7 +127,14 @@ END;; ...@@ -121,7 +127,14 @@ END;;
CREATE TRIGGER TRG_SESSION_CLOSED CREATE TRIGGER TRG_SESSION_CLOSED
AFTER UPDATE ON working_session AFTER UPDATE ON working_session
FOR EACH ROW 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 IF ((old.end IS NULL) and (new.end IS NOT NULL)) THEN
CALL deleteOpenTry(new.id); CALL deleteOpenTry(new.id);
END IF; END IF;
...@@ -134,7 +147,13 @@ END;; ...@@ -134,7 +147,13 @@ END;;
CREATE TRIGGER TRG_NEW_EVENT_ONSESSION CREATE TRIGGER TRG_NEW_EVENT_ONSESSION
BEFORE INSERT ON action BEFORE INSERT ON action
FOR EACH ROW 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 idstu INT;
DECLARE idtry INT; DECLARE idtry INT;
SET idstu=NEW.id_stu; SET idstu=NEW.id_stu;
...@@ -158,7 +177,14 @@ END;; ...@@ -158,7 +177,14 @@ END;;
CREATE TRIGGER TRG_NEW_EVENT CREATE TRIGGER TRG_NEW_EVENT
AFTER INSERT ON action AFTER INSERT ON action
FOR EACH ROW 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 idopentry INT;
DECLARE idsup_ws INT; DECLARE idsup_ws INT;
DECLARE idws INT; DECLARE idws INT;
...@@ -207,7 +233,14 @@ ALTER TABLE `working_session` ...@@ -207,7 +233,14 @@ ALTER TABLE `working_session`
CREATE TRIGGER TRG_SESSION_CLOSING CREATE TRIGGER TRG_SESSION_CLOSING
BEFORE UPDATE ON working_session BEFORE UPDATE ON working_session
FOR EACH ROW 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 IF ((new.end IS NOT NULL) AND (new.current IS NOT NULL)) THEN
SET new.current=NULL; SET new.current=NULL;
END IF; END IF;
...@@ -225,7 +258,13 @@ ALTER TABLE `action` ...@@ -225,7 +258,13 @@ ALTER TABLE `action`
CREATE TRIGGER TRG_TRY_EVALUATED CREATE TRIGGER TRG_TRY_EVALUATED
AFTER UPDATE ON try AFTER UPDATE ON try
FOR EACH ROW 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 idopentry INT;
DECLARE idws INT; DECLARE idws INT;
DECLARE ws_end DATE; DECLARE ws_end DATE;
...@@ -243,6 +282,3 @@ END;; ...@@ -243,6 +282,3 @@ END;;
DELIMITER ; DELIMITER ;
...@@ -9,13 +9,17 @@ describe('Student API', function () { ...@@ -9,13 +9,17 @@ describe('Student API', function () {
delete studentAgentData.password; delete studentAgentData.password;
studentAgentData.current_method = 'Test Method'; studentAgentData.current_method = 'Test Method';
studentAgentData.current_instruction = 'Test Instruction'; studentAgentData.current_instruction = 'Test Instruction';
supervisorAgent supervisorAgent
.get('/stu/' + studentAgent.data.id) .get('/stu/' + studentAgent.data.id)
.send() .send()
.expect(200) .expect(200)
.expect(studentAgentData) .expect(studentAgentData)
.end(done); .end((error) => {
if (error) {
throw error;
};
done();
});
}); });
it('GET /stu/:id_stu/supervisors', function (done) { it('GET /stu/:id_stu/supervisors', function (done) {
supervisorAgent supervisorAgent
......
...@@ -66,11 +66,12 @@ describe('Supervisor API', function () { ...@@ -66,11 +66,12 @@ describe('Supervisor API', function () {
}) })
.end(done); .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() supervisorAgent.get('/sup/' + supervisorAgent.data.id + '/pic_fromcategory/41').send()
.expect(200) .expect(200)
.expect(function (response) { .expect(function (response) {
assert.isArray(response.body); assert.isArray(response.body);
assert.isAtLeast(response.body.length, 1, 'category 41 is empty');
response.body.forEach(function (picto) { response.body.forEach(function (picto) {
assert.isObject(picto); assert.isObject(picto);
assert.isNumber(picto.source); assert.isNumber(picto.source);
......
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