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
80c829c3
authored
Mar 24, 2017
by
Arturo Montejo Ráez
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Added new attributes for picto
parent
48be7663
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
23 deletions
sails/src/api/controllers/StudentController.js
sails/src/api/models/StuPicto.js
sails/src/api/controllers/StudentController.js
View file @
80c829c3
...
...
@@ -95,24 +95,42 @@ module.exports = {
* @param {request} req {} (with studentId specified as url parameters)
* @param {response} res
* {
* id: 12,
* office: 1234,
* username: 'johnydoe',
* name: 'Johny',
* surname: 'Doe',
* birthdate: '2009-12-10T00:00:00.000Z',
* gender: 'F',
* country: 'ES',
* pic: 'avatar/nice/url.jpg',
* notes: null,
* lang: 'en-en',
* iat: 123512,
* exp: 1231292,
* attributes: { @see Student.getValidAttributes() },
* current_method: 'Do Things', // May be null
* current_instruction: 'Do Stuff', // May be null
* supervision: 0|1|2, // supervision level according to requester 0 -> office admin, 1 -> tutor, 2 -> therapist
* }
"office": 383,
"id": 92,
"username": "jose",
"name": "AAjose",
"surname": "AAjose antonio",
"birthdate": "2009-05-12T00:00:00.000Z",
"gender": "M",
"country": "ES",
"pic": "/upload/studentAvatar/defaultAvatar.jpg",
"notes": "",
"lang": "es-es",
"current_method": "Comunicación Aumentativa y Adaptativa", // May be "no method"
"current_instruction": "Fase 4 - Estructura de la oración", // May be "no instruction"
"supervision": 2 // supervision level according to requester 0 -> office admin, 1 -> tutor, 2 -> therapist, 3 -> student himself
"attributes": { @see Student.getValidAttributes()
"categories": true,
"input_feedback": {
"vibration": true,
"read": false,
"beep": false,
"highlight": false
},
"input_selection": {
"click": true,
"double_click": false,
"long_press": false,
"drag": true
},
"legend": false,
"legend_size": "normal",
"size": "large",
"picto_background": "#0000ff",
"tape_background": "#00ffff",
"delivery": 0
}
}
*/
getInfo
:
function
(
req
,
res
)
{
Student
.
findOne
({
id
:
req
.
params
.
id_stu
})
...
...
@@ -144,9 +162,9 @@ module.exports = {
else
if
(
stu_sup
&&
!
req
.
token
.
office
)
student
.
supervision
=
1
;
// requester is tutor of the studend
else
if
(
stu_sup
&&
req
.
token
.
office
&&
student
.
office
==
req
.
token
.
office
.
id
)
student
.
supervision
=
2
;
// requester is supervisor of student
else
if
(
req
.
token
.
isStudent
&&
req
.
token
.
id
==
student
.
id
)
student
.
supervision
=
3
// requester is the student himself
student
.
supervision
=
2
;
// requester is supervisor of student
else
if
(
req
.
token
.
isStudent
&&
req
.
token
.
id
==
student
.
id
)
student
.
supervision
=
3
// requester is the student himself
if
(
student
.
supervision
==
-
1
)
// should not hace access!!!
return
res
.
forbidden
(
"Access to this student should not be granted to you"
);
...
...
@@ -966,7 +984,9 @@ module.exports = {
* legend: true/[false],
* legend_size: '[small]/large',
* expression: 'custom expression',
* color: any valid HEX color or [null]
* color: any valid HEX color or [null],
* sound_uri: path to sound file,
* user_avatar: email (supervisor) or username (student) for associated account
* }
* },
* }
...
...
sails/src/api/models/StuPicto.js
View file @
80c829c3
...
...
@@ -90,6 +90,8 @@ module.exports = {
color
:
null
,
expression
:
null
,
legend
:
'none'
,
uri_sound
:
null
,
user_avatar
:
null
};
if
(
typeof
attributes
===
'object'
)
{
...
...
@@ -128,13 +130,19 @@ module.exports = {
}
if
(
!
((
/^
(
none|normal|full
)
$/
).
test
(
validAttributes
.
legend
)))
{
delete
validAttributes
.
legend
;
}
}
if
(
typeof
validAttributes
.
highlight
!==
'boolean'
)
{
delete
validAttributes
.
highlight
;
}
if
(
!
((
/^#
([
0-9a-f
]{3}){1,2}
$/i
).
test
(
validAttributes
.
color
)))
{
delete
validAttributes
.
color
;
}
if
(
typeof
validAttributes
.
sound_uri
!==
'string'
)
{
delete
validAttributes
.
sound_uri
;
}
if
(
typeof
validAttributes
.
user_avatar
!==
'string'
)
{
delete
validAttributes
.
user_avatar
;
}
}
sails
.
log
.
verbose
(
'Valid attributes for StuPicto'
,
validAttributes
);
return
Object
.
assign
({},
defaultAttributes
,
validAttributes
);
...
...
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