Commit bf14c730 authored by Bruno Meyer's avatar Bruno Meyer 😢 Committed by Matheus Horstmann

#6: Create Turma and Evento models

parent ea23f8ef
......@@ -6,7 +6,8 @@ var app = require(path.resolve(__dirname, '../server/server'));
var ds = app.datasources.ensalamento;
var lbTables = ['User','AccessToken','ACL','RoleMapping','Role','Sala','Bloco','Disciplina', 'Equivalenciadisciplina'];
var lbTables = ['User','AccessToken','ACL','RoleMapping','Role','Sala','Bloco','Disciplina', 'Equivalenciadisciplina', 'Evento', 'Turma'];
ds.automigrate(lbTables, function(err) {
if (err) throw err;
......
......@@ -9,6 +9,8 @@
* restrita : **boolean** `Required`, default=`false`
- ACLs
* All permissions not specified is `DENY`
* **$everyone** ROLE have all READ operations
* **admin** ROLE have all EXECUTE, READ and WRITE operations
- Relations
* Belongs to : **Bloco**
......@@ -19,7 +21,7 @@
* tamanho : **number** `Required`, default=`0`
- ACLs
* All permissions not specified is `DENY`
* **$authenticated** ROLE have all READ operations
* **$everyone** ROLE have all READ operations
* **admin** ROLE have all EXECUTE, READ and WRITE operations
- Relations
* Has many : **Sala** `nestRemoting`, `disableInclude`
......@@ -33,9 +35,12 @@
* modalidade : **string** `Required`, default=`presencial`
- ACLs
* All permissions not specified is `DENY`
* **$everyone** ROLE have all READ operations
* **admin** ROLE have all EXECUTE, READ and WRITE operations
- Relations
* This model have a self-realtion. To implement this, we use the EquivalenciaDisciplina model
* Has Many : **Turma** `Required (in Turma)` as `disciplinaId (in Turma)`
## EquivalenciaDisciplina
- Public: `False`
......@@ -47,3 +52,31 @@
- Relations
* Belongs To : **Disciplina** `Required` as `disciplina1`
* Belongs To : **Disciplina** `Required` as `disciplina2`
## Evento (server-side)
- Public: `False`
- Description: This will be extended by `Turma`
- Attributes
* organizador : **sting** `Required`
* vagas : **number** `Required`
* ano : **number** `Required`
* periodo : **string** `Required`
- ACLs
* All permissions not specified is `DENY`
* **$everyone** ROLE have all READ operations
* **admin** ROLE have all EXECUTE, READ and WRITE operations
- Relations
* `Model Disciplina has a relation Has Many on this`
## Turma
- Public: `True`
- Description: This model extend `Evento`
- Attributes
* horarios : **date** `Required`
* data_inicio : **date** `Required`
* data_fim : **date** `Required`
- ACLs
* All permissions not specified is `DENY`
* **$everyone** ROLE have all READ operations
* **admin** ROLE have all EXECUTE, READ and WRITE operations
- Relations
......@@ -44,7 +44,7 @@
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$authenticated",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
......
......@@ -75,7 +75,34 @@
}
},
"validations": [],
"relations": {},
"relations": {
"turmas": {
"type": "hasMany",
"model": "Turma",
"foreignKey": "disciplinaId",
"required": true
}
},
"acls": [
{
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY",
"property": "*"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW",
"property": "*"
}
],
"methods": {
"prototype.addEquivalencia": {
"accepts": [
......@@ -120,19 +147,5 @@
"path": "/deleteEquivalencia"
}
}
},
"acls": [
{
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY",
"property": "*"
},
{
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW",
"property": "*"
}
]
}
}
......@@ -46,6 +46,18 @@
"principalId": "$everyone",
"permission": "DENY",
"property": "*"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW",
"property": "*"
}
],
"methods": {}
......
'use strict';
module.exports = function(Turma) {
Turma.validatesPresenceOf('disciplinaId');
};
{
"name": "Turma",
"plural": "turmas",
"base": "Evento",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"horarios": {
"type": "date",
"required": true
},
"data_inicio": {
"type": "date",
"required": true
},
"data_fim": {
"type": "date",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [
{
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY",
"property": "*"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$authenticated",
"permission": "ALLOW"
},
{
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW",
"property": "*"
}
],
"methods": {}
}
......@@ -50,5 +50,13 @@
"Equivalenciadisciplina": {
"dataSource": "ensalamento",
"public": false
},
"Evento": {
"dataSource": "ensalamento",
"public": false
},
"Turma": {
"dataSource": "ensalamento",
"public": true
}
}
'use strict';
module.exports = function(Evento) {
};
{
"name": "Evento",
"plural": "eventos",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"organizador": {
"type": "string",
"required": true
},
"vagas": {
"type": "number",
"required": true
},
"ano": {
"type": "number",
"required": true
},
"periodo": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [
{
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY",
"property": "*"
},
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW",
"property": "*"
}
],
"methods": {}
}
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 to comment