Commit 828342a4 authored by Bruno Meyer's avatar Bruno Meyer 😢

#7 Create TipoDeSala model

parent 4d8b3919
......@@ -18,13 +18,15 @@ var lbTables = [
'Evento',
'Turma',
'Recursodesala',
'DisciplinaRecursodesala'
'DisciplinaRecursodesala',
'SalaRecursodesala',
'Tipodesala'
];
ds.automigrate(lbTables, function(err) {
if (err) throw err;
async.waterfall([criaBloco,criaSala,criaUser,criaDisciplina, criaEquivalencia, criaRecursodesala], function(err) {
async.waterfall([criaBloco,criaSala,criaUser,criaDisciplina, criaEquivalencia, criaRecursodesala, criaTipodesala], function(err) {
if (err) throw err;
ds.disconnect();
})
......@@ -85,6 +87,22 @@ function criaRecursodesala(cb){
});
}
function criaTipodesala(cb){
var tipos = [
{nome: 'tipo1'},
{nome: 'tipo2'}
];
async.each(tipos, function(tipo, callback) {
app.models.Tipodesala.create(tipo, function(err, model) {
callback(err);
console.log('Created:', model);
});
}, function(err) {
if (err) throw err;
cb(err);
});
}
function criaUser(cb){
app.models.User.create([
......
......@@ -13,6 +13,7 @@
* **admin** ROLE have all EXECUTE, READ and WRITE operations
- Relations
* Belongs to : **Bloco**
* Has and Belongs To Many : **Recursodesala** as `recursos`
## Bloco
- Public: `True`
......@@ -40,7 +41,7 @@
- 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)`
* Has and Belongs To Many : **Recursodesala**
* Has and Belongs To Many : **Recursodesala** as `recursosnecessarios`
## EquivalenciaDisciplina
......@@ -84,6 +85,10 @@
## Recursodesala
- Public: `False`
- Description: This model contains the resources listage of rooms.
In future, this can be use to allocate a room to disciplinas.
In this case, a disciplina must gain a room that meet this
resources needs.
- Attributes
* descricao : **string** `Required`
- ACLs
......@@ -91,3 +96,25 @@
* **$everyone** ROLE have all READ operations
* **admin** ROLE have all EXECUTE, READ and WRITE operations
- Relations
- Observation: In future, its possible that will be necessary to find
rooms filtering by resources. Loopback gives a set of utilities
to solve many types of this problems, including filtering
relations: https://loopback.io/doc/en/lb3/Include-filter.html
## Tipodesala
- Public: `False`
- Description: This model contains the types of rooms listage.
In future, this can be use to allocate a room to disciplinas.
In this case, a disciplina must gain a room that meet this
room type need.
- Attributes
* nome : **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
- Observation: In future, its possible that will be necessary to find
rooms filtering by resources. Loopback gives a set of utilities
to solve many types of this problems, including filtering
relations: https://loopback.io/doc/en/lb3/Include-filter.html
\ No newline at end of file
......@@ -46,6 +46,11 @@
"type": "hasAndBelongsToMany",
"model": "Recursodesala",
"foreignKey": ""
},
"tipo_sala_necessaria": {
"type": "belongsTo",
"model": "Tipodesala",
"foreignKey": "tipodesalaId"
}
},
"acls": [
......
......@@ -38,6 +38,16 @@
"type": "belongsTo",
"model": "Bloco",
"foreignKey": ""
},
"recursos": {
"type": "hasAndBelongsToMany",
"model": "Recursodesala",
"foreignKey": ""
},
"tipo": {
"type": "belongsTo",
"model": "Tipodesala",
"foreignKey": "tipodesalaId"
}
},
"acls": [
......
'use strict';
module.exports = function(Tipodesala) {
};
{
"name": "Tipodesala",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"nome": {
"type": "string",
"required": true,
"default": "normal"
}
},
"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": {}
}
......@@ -62,5 +62,9 @@
"Recursodesala": {
"dataSource": "ensalamento",
"public": false
},
"Tipodesala": {
"dataSource": "ensalamento",
"public": false
}
}
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