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
6ac4f1af
authored
Jun 09, 2016
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
database files cleaned and fixed, logs paths corrected
parent
6bb23868
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
90 additions
and
50 deletions
android/.idea/workspace.xml
android/Pictogram/app/build.gradle
android/Pictogram/build.gradle
android/Pictogram/gradle/wrapper/gradle-wrapper.properties
sails/roles/database/files/init-ignoresymbolstix.sql
sails/roles/database/files/pictodb-schema.sql
sails/roles/database/files/triggers-sessions-integrity-constraints.sql
sails/roles/database/tasks/main.yml
sails/roles/database/vars/main.yml
sails/src/api/controllers/StudentController.js
sails/src/config/log.js
sails/src/test/api/sup-spec.js
sails/src/test/test-helper.js
android/.idea/workspace.xml
View file @
6ac4f1af
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ChangeListManager"
>
<list
default=
"true"
id=
"10daeba4-0692-476d-a3da-642b4123cfdd"
name=
"Default"
comment=
""
>
<change
type=
"MODIFICATION"
beforePath=
"$PROJECT_DIR$/.idea/workspace.xml"
afterPath=
"$PROJECT_DIR$/.idea/workspace.xml"
/>
</list>
<list
default=
"true"
id=
"10daeba4-0692-476d-a3da-642b4123cfdd"
name=
"Default"
comment=
""
/>
<ignored
path=
"android.iws"
/>
<ignored
path=
".idea/workspace.xml"
/>
<option
name=
"EXCLUDED_CONVERTED_TO_IGNORED"
value=
"true"
/>
...
...
@@ -38,10 +36,10 @@
</option>
</component>
<component
name=
"ProjectFrameBounds"
>
<option
name=
"x"
value=
"
44
"
/>
<option
name=
"y"
value=
"2
3
"
/>
<option
name=
"width"
value=
"1
397
"
/>
<option
name=
"height"
value=
"
877
"
/>
<option
name=
"x"
value=
"
65
"
/>
<option
name=
"y"
value=
"2
4
"
/>
<option
name=
"width"
value=
"1
615
"
/>
<option
name=
"height"
value=
"
1026
"
/>
</component>
<component
name=
"ProjectLevelVcsManager"
settingsEditedManually=
"true"
>
<OptionsSetting
value=
"true"
id=
"Add"
/>
...
...
@@ -57,7 +55,7 @@
<option
name=
"STATE"
value=
"0"
/>
</component>
<component
name=
"ProjectView"
>
<navigator
currentView=
"
ProjectPane
"
proportions=
""
version=
"1"
>
<navigator
currentView=
"
Scope"
currentSubView=
"Project Files
"
proportions=
""
version=
"1"
>
<flattenPackages
/>
<showMembers
/>
<showModules
/>
...
...
@@ -71,9 +69,6 @@
<foldersAlwaysOnTop
value=
"true"
/>
</navigator>
<panes>
<pane
id=
"AndroidView"
>
<subPane
/>
</pane>
<pane
id=
"ProjectPane"
>
<subPane>
<PATH>
...
...
@@ -84,10 +79,13 @@
</PATH>
</subPane>
</pane>
<pane
id=
"PackagesPane"
>
<subPane
/>
</pane>
<pane
id=
"Scope"
>
<subPane
subId=
"Project Files"
/>
</pane>
<pane
id=
"
PackagesPane
"
>
<pane
id=
"
AndroidView
"
>
<subPane
/>
</pane>
<pane
id=
"Scratches"
/>
...
...
@@ -295,7 +293,7 @@
<servers
/>
</component>
<component
name=
"ToolWindowManager"
>
<frame
x=
"
44"
y=
"23"
width=
"1397"
height=
"877"
extended-state=
"0
"
/>
<frame
x=
"
65"
y=
"24"
width=
"1615"
height=
"1026"
extended-state=
"6
"
/>
<editor
active=
"false"
/>
<layout>
<window_info
id=
"Palette	"
active=
"false"
anchor=
"left"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"2"
side_tool=
"false"
content_ui=
"tabs"
/>
...
...
@@ -303,8 +301,8 @@
<window_info
id=
"Terminal"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"7"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"TODO"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"6"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Capture Analysis"
active=
"false"
anchor=
"right"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"4"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Structure"
active=
"false"
anchor=
"left"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.249
4465
"
sideWeight=
"0.5"
order=
"1"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Project"
active=
"true"
anchor=
"left"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"true"
show_stripe_button=
"true"
weight=
"0.1744
186
"
sideWeight=
"0.5"
order=
"0"
side_tool=
"false"
content_ui=
"combo"
/>
<window_info
id=
"Structure"
active=
"false"
anchor=
"left"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.249
05898
"
sideWeight=
"0.5"
order=
"1"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Project"
active=
"true"
anchor=
"left"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"true"
show_stripe_button=
"true"
weight=
"0.1744
0401
"
sideWeight=
"0.5"
order=
"0"
side_tool=
"false"
content_ui=
"combo"
/>
<window_info
id=
"Debug"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.4"
sideWeight=
"0.5"
order=
"3"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Run"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"2"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Favorites"
active=
"false"
anchor=
"left"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"2"
side_tool=
"true"
content_ui=
"tabs"
/>
...
...
@@ -314,19 +312,19 @@
<window_info
id=
"Changes"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"7"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Ant Build"
active=
"false"
anchor=
"right"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.25"
sideWeight=
"0.5"
order=
"1"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Android Monitor"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"7"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Build Variants"
active=
"false"
anchor=
"left"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"3"
side_tool=
"true"
content_ui=
"tabs"
/>
<window_info
id=
"Gradle Console"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"7"
side_tool=
"true"
content_ui=
"tabs"
/>
<window_info
id=
"Build Variants"
active=
"false"
anchor=
"left"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"3"
side_tool=
"true"
content_ui=
"tabs"
/>
<window_info
id=
"Application Servers"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"7"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Hierarchy"
active=
"false"
anchor=
"right"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.25"
sideWeight=
"0.5"
order=
"2"
side_tool=
"false"
content_ui=
"combo"
/>
<window_info
id=
"Memory Monitor"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"7"
side_tool=
"true"
content_ui=
"tabs"
/>
<window_info
id=
"Cvs"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.25"
sideWeight=
"0.5"
order=
"4"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Android Model"
active=
"false"
anchor=
"right"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"4"
side_tool=
"true"
content_ui=
"tabs"
/>
<window_info
id=
"Palette"
active=
"false"
anchor=
"right"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"3"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Android Model"
active=
"false"
anchor=
"right"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"4"
side_tool=
"true"
content_ui=
"tabs"
/>
<window_info
id=
"Message"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"0"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Find"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"1"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Captures"
active=
"false"
anchor=
"left"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"3"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Commander"
active=
"false"
anchor=
"right"
auto_hide=
"false"
internal_type=
"SLIDING"
type=
"SLIDING"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.4"
sideWeight=
"0.5"
order=
"0"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Maven Projects"
active=
"false"
anchor=
"right"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.33"
sideWeight=
"0.5"
order=
"3"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Commander"
active=
"false"
anchor=
"right"
auto_hide=
"false"
internal_type=
"SLIDING"
type=
"SLIDING"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.4"
sideWeight=
"0.5"
order=
"0"
side_tool=
"false"
content_ui=
"tabs"
/>
<window_info
id=
"Inspection"
active=
"false"
anchor=
"bottom"
auto_hide=
"false"
internal_type=
"DOCKED"
type=
"DOCKED"
visible=
"false"
show_stripe_button=
"true"
weight=
"0.4"
sideWeight=
"0.5"
order=
"5"
side_tool=
"false"
content_ui=
"tabs"
/>
</layout>
</component>
...
...
android/Pictogram/app/build.gradle
View file @
6ac4f1af
...
...
@@ -44,16 +44,13 @@ android {
resValue
"string"
,
"server"
,
"https://127.0.0.1:9944"
applicationId
"com.yottacode.pictogrammar"
}
Arturo
Flavor
{
Local
Flavor
{
resValue
"string"
,
"server"
,
"https://192.168.1.37:1337"
}
DefaultFlavor
{
resValue
"string"
,
"server"
,
"https://pre.yottacode.com"
signingConfig
signingConfigs
.
release_config
}
ArturoFlavorNoSSL
{
resValue
"string"
,
"server"
,
"http://192.168.1.37:1337"
}
}
}
...
...
android/Pictogram/build.gradle
View file @
6ac4f1af
...
...
@@ -5,7 +5,7 @@ buildscript {
jcenter
()
}
dependencies
{
classpath
'com.android.tools.build:gradle:
1.5
.0'
classpath
'com.android.tools.build:gradle:
2.1
.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
...
...
android/Pictogram/gradle/wrapper/gradle-wrapper.properties
View file @
6ac4f1af
#
Wed Apr 10 15:27:10 PDT 2013
#
Mon Jun 06 22:38:39 CEST 2016
distributionBase
=
GRADLE_USER_HOME
distributionPath
=
wrapper/dists
zipStoreBase
=
GRADLE_USER_HOME
zipStorePath
=
wrapper/dists
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-2.
2.1
-all.zip
distributionUrl
=
https
\:
//services.gradle.org/distributions/gradle-2.
10
-all.zip
sails/roles/database/files/init-ignoresymbolstix.sql
View file @
6ac4f1af
...
...
@@ -10,7 +10,7 @@ SET foreign_key_checks=0;
SET
@
TRIGGER_CHECKS
=
FALSE
;
DELETE
FROM
picto_tag
WHERE
`id_sup`
IS
NOT
NULL
;
DELETE
FROM
picto
WHERE
`owner`
IS
NOT
NULL
;
DELETE
FROM
picto
WHERE
`
id_
owner`
IS
NOT
NULL
;
TRUNCATE
office
;
TRUNCATE
supervisor
;
TRUNCATE
student
;
...
...
@@ -20,6 +20,16 @@ TRUNCATE method;
TRUNCATE
instruction
;
TRUNCATE
try
;
TRUNCATE
working_session
;
DROP
TRIGGER
IF
EXISTS
TRG_NEW_STUDENT_MAXENROLMENTS
;
DROP
TRIGGER
IF
EXISTS
TRG_NEW_STUDENT_UPDATE_ENROLMENTS
;
DROP
TRIGGER
IF
EXISTS
TRG_MODIFY_STUDENT_ENROLMENTS
;
DROP
TRIGGER
IF
EXISTS
TRG_DELETE_STUDENT_ENROLMENTS
;
DROP
TRIGGER
IF
EXISTS
TRG_SESSION_NEW
;
DROP
TRIGGER
IF
EXISTS
TRG_SESSION_CLOSED
;
DROP
TRIGGER
IF
EXISTS
TRG_NEW_EVENT_ONSESSION
;
DROP
TRIGGER
IF
EXISTS
TRG_NEW_EVENT
;
DROP
TRIGGER
IF
EXISTS
TRG_SESSION_CLOSING
;
DROP
TRIGGER
IF
EXISTS
TRG_TRY_EVALUATED
;
SET
@
TRIGGER_CHECKS
=
TRUE
;
SET
foreign_key_checks
=
1
;
sails/roles/database/files/pictodb-schema.sql
View file @
6ac4f1af
...
...
@@ -394,7 +394,15 @@ CREATE TABLE IF NOT EXISTS `working_session` (
`description`
varchar
(
1024
)
COLLATE
utf8_unicode_ci
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
),
KEY
`id_sup`
(
`id_sup`
),
KEY
`id_ins`
(
`id_ins`
)
KEY
`id_ins`
(
`id_ins`
),
-- Integrity rule 6: It is not possible to open a new session when a previous session is opened for a given supervisor
-- when: state SES and PAU, event a2
-- (see triggers-sessions-integrity-constraints for the rest of rules)
--
CONSTRAINT
`idx_ws_supcur`
UNIQUE
(
id_sup
,
current
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COLLATE
=
utf8_unicode_ci
AUTO_INCREMENT
=
1
COMMENT
=
"This table stores working session information. Every working session is related to one instruction and one supervisor (and the instruction is related to one method which is related to one student)"
;
...
...
@@ -409,6 +417,12 @@ ALTER TABLE `action`
ADD
CONSTRAINT
`fk_stu_act`
FOREIGN
KEY
(
`id_stu`
)
REFERENCES
`student`
(
`id`
),
ADD
CONSTRAINT
`fk_sup_act`
FOREIGN
KEY
(
`id_sup`
)
REFERENCES
`supervisor`
(
`id`
);
-- Integrity rule 8: Every action requires a valid try or null
-- when: state SES, event a3 and a5
-- (see triggers-sessions-integrity-constraints for the rest of rules)
--
ALTER
TABLE
`action`
ADD
CONSTRAINT
`fk_try_act`
FOREIGN
KEY
(
`id_try`
)
REFERENCES
`try`
(
`id`
)
ON
DELETE
SET
NULL
;;
--
...
...
@@ -506,6 +520,7 @@ ALTER TABLE `supervisor`
ALTER
TABLE
`try`
ADD
CONSTRAINT
`try_ibfk_1`
FOREIGN
KEY
(
`id_ws`
)
REFERENCES
`working_session`
(
`id`
)
ON
DELETE
CASCADE
;
--
-- Filtros para la tabla `working_session`
--
...
...
@@ -521,7 +536,7 @@ ALTER TABLE `working_session`
CREATE
ALGORITHM
=
UNDEFINED
VIEW
`v_stu_last_ws_time`
AS
SELECT
M
.
`id_stu`
AS
id_stu
,
SELECT
M
.
`id_stu`
AS
id_stu
,
MAX
(
WS
.
begin
)
AS
time
FROM
`working_session`
AS
WS
join
...
...
@@ -532,6 +547,7 @@ SELECT M.`id_stu`AS id_stu,
and
I
.
`id_met`
=
M
.
`id`
group
by
M
.
`id_stu`
;
CREATE
ALGORITHM
=
UNDEFINED
VIEW
`v_stu_last_instruction`
AS
select
...
...
sails/roles/database/files/triggers-sessions-integrity-constraints.sql
View file @
6ac4f1af
...
...
@@ -228,14 +228,6 @@ thisTrigger: BEGIN
END
;;
-- Integrity rule 6: It is not possible to open a new session when a previous session is opened for a given supervisor
-- when: state SES and PAU, event a2
--
ALTER
TABLE
`working_session`
ADD
CONSTRAINT
`idx_ws_supcur`
UNIQUE
(
id_sup
,
current
);;
-- Integrity rule 2: when a session is closed, last try must be discharged
-- when: state COM, event a4
-- current is to NULL (integrity rule 6)
...
...
@@ -257,12 +249,6 @@ thisTrigger: BEGIN
END
IF
;
END
;;
-- Integrity rule 8: Every action requires a valid try or null
-- when: state SES, event a3 and a5
--
ALTER
TABLE
`action`
ADD
CONSTRAINT
`fk_try_act`
FOREIGN
KEY
(
`id_try`
)
REFERENCES
`try`
(
`id`
)
ON
DELETE
SET
NULL
;;
--
-- Required for not closed sessions policy retrieving
--
...
...
sails/roles/database/tasks/main.yml
View file @
6ac4f1af
...
...
@@ -7,6 +7,7 @@
name
:
all
state
:
import
target
:
"
{{
server_path
}}/{{
database_files_relative_path
}}/init.sql"
tags
:
reset-test-database
-
name
:
Imports the pictodb Schema
mysql_db
:
...
...
@@ -15,6 +16,8 @@
name
:
"
{{
database_name
}}"
state
:
import
target
:
"
{{
server_path
}}/{{
database_files_relative_path
}}/pictodb-schema.sql"
tags
:
-
reset-test-database
-
name
:
Imports symbolstx categories and metadata
mysql_db
:
...
...
@@ -23,6 +26,8 @@
name
:
"
{{
database_name
}}"
state
:
import
target
:
"
{{
server_path
}}/{{
database_files_relative_path
}}/symbolstx-{{
item
}}.sql"
tags
:
-
reset-test-database
with_items
:
-
categories
-
metadata
...
...
@@ -34,6 +39,8 @@
name
:
"
{{
database_name
}}"
state
:
import
target
:
"
{{
server_path
}}/{{
database_files_relative_path
}}/pictodb-data.sql"
tags
:
-
reset-test-database
-
name
:
Imports selected tests
mysql_db
:
...
...
@@ -42,6 +49,8 @@
name
:
"
{{
database_name
}}"
state
:
import
target
:
"
{{
server_path
}}/{{
database_files_relative_path
}}/test-{{
item
}}.sql"
tags
:
-
reset-test-database
with_items
:
"
{{
database_tests
}}"
-
name
:
Creates triggers
...
...
@@ -51,6 +60,8 @@
name
:
"
{{
database_name
}}"
state
:
import
target
:
"
{{
server_path
}}/{{
database_files_relative_path
}}/triggers-{{
item
}}.sql"
tags
:
-
reset-test-database
with_items
:
-
enrolments-integrity-constraints
-
sessions-integrity-constraints
sails/roles/database/vars/main.yml
View file @
6ac4f1af
...
...
@@ -4,4 +4,4 @@ database_root_passwd: root
database_name
:
pictodb
database_user
:
pictodbuser
database_user_passwd
:
p1KT015
database_tests
:
[
caja
,
autismojaen
]
# can be empty
database_tests
:
[
caja
]
#[caja
, autismojaen] # can be empty
sails/src/api/controllers/StudentController.js
View file @
6ac4f1af
...
...
@@ -41,14 +41,17 @@ module.exports = {
*/
login
:
function
(
req
,
res
)
{
var
bcrypt
=
require
(
'bcrypt-nodejs'
);
console
.
log
(
'1'
);
Student
.
findOne
({
username
:
req
.
body
.
username
})
.
then
(
function
(
student
)
{
console
.
log
(
'2'
);
if
(
student
)
{
console
.
log
(
'3'
);
if
(
bcrypt
.
compareSync
(
req
.
body
.
password
,
student
.
password
))
{
student
.
isStudent
=
true
;
console
.
log
(
'4'
);
res
.
ok
({
user
:
student
,
token
:
sailsTokenAuth
.
issueToken
(
student
,
sails
.
config
.
jwt
.
expiresInMinutes
),
...
...
@@ -56,6 +59,7 @@ module.exports = {
.
getTime
()
});
}
else
{
console
.
log
(
'5'
);
sails
.
log
.
error
(
`Invalid student login: user
${
student
.
username
}
, password\
"
${
req
.
body
.
password
}
"`
);
res
.
badRequest
();
...
...
@@ -113,7 +117,7 @@ module.exports = {
}
res
.
ok
(
student
);
})
.
catch
(
function
()
{
.
catch
(
function
(
error
)
{
res
.
serverError
();
});
}
else
{
...
...
sails/src/config/log.js
View file @
6ac4f1af
...
...
@@ -26,7 +26,7 @@ customLogger.add(winston.transports.File, {
json
:
true
,
tailable
:
true
,
maxsize
:
5
*
1024
*
1024
,
// 5 MegaByte
filename
:
path
.
resolve
(
__dirname
,
'..'
,
'logs'
,
'silly.json'
)
filename
:
path
.
resolve
(
__dirname
,
'..
/..
'
,
'logs'
,
'silly.json'
)
});
customLogger
.
add
(
winston
.
transports
.
File
,
{
...
...
@@ -39,7 +39,7 @@ customLogger.add(winston.transports.File, {
json
:
true
,
tailable
:
true
,
maxsize
:
5
*
1024
*
1024
,
// 5 MegaByte
filename
:
path
.
resolve
(
__dirname
,
'..'
,
'logs'
,
'debug.json'
)
filename
:
path
.
resolve
(
__dirname
,
'..
/..
'
,
'logs'
,
'debug.json'
)
});
customLogger
.
add
(
winston
.
transports
.
File
,
{
...
...
@@ -52,7 +52,7 @@ customLogger.add(winston.transports.File, {
json
:
true
,
tailable
:
true
,
maxsize
:
5
*
1024
*
1024
,
// 5 MegaByte
filename
:
path
.
resolve
(
__dirname
,
'..'
,
'logs'
,
'error.json'
)
filename
:
path
.
resolve
(
__dirname
,
'..
/..
'
,
'logs'
,
'error.json'
)
});
module
.
exports
.
log
=
{
...
...
sails/src/test/api/sup-spec.js
View file @
6ac4f1af
...
...
@@ -66,7 +66,7 @@ describe('Supervisor API', function () {
})
.
end
(
done
);
});
it
.
only
(
'GET /sup/:id/pic_fromcategory/:id_cat'
,
function
(
done
)
{
it
(
'GET /sup/:id/pic_fromcategory/:id_cat'
,
function
(
done
)
{
supervisorAgent
.
get
(
'/sup/'
+
supervisorAgent
.
data
.
id
+
'/pic_fromcategory/41'
).
send
()
.
expect
(
200
)
.
expect
(
function
(
response
)
{
...
...
sails/src/test/test-helper.js
View file @
6ac4f1af
...
...
@@ -2,6 +2,8 @@
var
DATABASE_BACKUP_FILE
=
'/tmp/pictogram_test_backup.sql'
;
var
DATABASE_RESET_FILE
=
'../roles/database/files/init-ignoresymbolstix.sql'
var
DATABASE_SESSION_TRIGGERS_FILE
=
'../roles/database/files/triggers-sessions-integrity-constraints.sql'
var
DATABASE_ENROLMENT_TRIGGERS_FILE
=
'../roles/database/files/triggers-enrolments-integrity-constraints.sql'
var
DATABASE_TESTDATA_FILE
=
'../roles/database/files/test-caja.sql'
var
UPLOAD_FOLDER
;
var
UPLOAD_FOLDER_BACKUP
;
...
...
@@ -18,17 +20,32 @@ before(function (serverLoadDone) {
sails
=
new
Sails
();
// Backup the whole database
console
.
log
(
'-- Backing up database'
);
childProcess
.
execSync
(
'mysqldump -u pictodbuser -pp1KT015 pictodb > '
+
DATABASE_BACKUP_FILE
);
// Prepare with test data
console
.
log
(
'-- Preparing test database'
);
childProcess
.
execSync
(
'mysql -u pictodbuser -pp1KT015 pictodb < '
+
DATABASE_RESET_FILE
);
childProcess
.
execSync
(
'mysql -u pictodbuser -pp1KT015 pictodb < '
+
DATABASE_TESTDATA_FILE
);
childProcess
.
execSync
(
'mysql -u pictodbuser -pp1KT015 pictodb < '
+
DATABASE_SESSION_TRIGGERS_FILE
);
childProcess
.
execSync
(
'mysql -u pictodbuser -pp1KT015 pictodb < '
+
DATABASE_ENROLMENT_TRIGGERS_FILE
);
console
.
log
(
'-- Lifting Sails'
);
sails
.
lift
({},
function
(
error
)
{
if
(
error
)
{
console
.
log
(
error
.
stack
);
throw
error
;
}
console
.
log
(
'-- Importing bcrypt '
);
var
bcrypt
=
require
(
'bcrypt-nodejs'
);
// Backup the sail's upload folder
UPLOAD_FOLDER
=
sails
.
config
.
pictogram
.
paths
.
upload
;
UPLOAD_FOLDER_BACKUP
=
UPLOAD_FOLDER
+
'.backup'
;
console
.
log
(
'-- Backing up '
+
UPLOAD_FOLDER
);
childProcess
.
execSync
(
'cp -r '
+
UPLOAD_FOLDER
+
' '
+
UPLOAD_FOLDER_BACKUP
);
// Publish chai testing methods
...
...
@@ -77,9 +94,10 @@ before(function (serverLoadDone) {
});
after
(
function
(
done
)
{
console
.
log
(
'-- Restoring backups'
);
// Restore the database and the upload folder
if
(
UPLOAD_FOLDER
&&
UPLOAD_FOLDER_BACKUP
)
{
childProcess
.
execSync
(
'mysql -u
pictodbuser -pp1KT015
pictodb < '
+
DATABASE_BACKUP_FILE
);
childProcess
.
execSync
(
'mysql -u
root -proot
pictodb < '
+
DATABASE_BACKUP_FILE
);
childProcess
.
execSync
(
'rm '
+
DATABASE_BACKUP_FILE
);
childProcess
.
execSync
(
'rm -r '
+
UPLOAD_FOLDER
);
childProcess
.
execSync
(
'mv '
+
UPLOAD_FOLDER_BACKUP
+
' '
+
UPLOAD_FOLDER
);
...
...
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