Commit 215f38c9 authored by Odair M.'s avatar Odair M.

Merge branch 'development' of...

Merge branch 'development' of https://gitlab.c3sl.ufpr.br/ensalamento/ensalamento-back into development
parents 5b9a81c2 69a4bbbd
'use strict';
var app = require('../../server/server');
module.exports = function(Curso) {
Curso.search = async function(query) {
var _query = {ilike:"%"+query+"%"}
var _include = {disciplinas:{turmas:["professor", "horarios"]}}
var cursos = await app.models.Curso.find({where:
{or: [{nome: _query},
{codigo: _query}]}, include:_include})
// TODO
return cursos;
};
};
......@@ -61,7 +61,41 @@
"principalId": "comissao",
"permission": "ALLOW",
"property": "*"
},
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW",
"property": "search"
}
],
"methods": {}
"methods": {
"search": {
"accepts": [
{
"arg": "query",
"type": "string",
"required": true,
"description": "query string"
}
],
"returns": [
{
"arg": "retorno",
"type": "array",
"root": false,
"description": "retorno"
}
],
"description": "search",
"http": [
{
"path": "/search",
"verb": "get"
}
]
}
}
}
'use strict';
var app = require('../../server/server');
module.exports = function(Departamento) {
Departamento.search = async function(query) {
var _query = {ilike:"%"+query+"%"}
//como o é utilizado somente o código da sala, não precisa incluir a
//relacao sala
var _include = {turmas:["professor","disciplina","cursos","horarios"]}
//var _include = {turmas:["professor","disciplina","cursos",{horarios:["sala"]}]}
var dpts = await app.models.Departamento.find({where:
{or: [ {nome: _query},
{codigo: _query} ]},include:_include})
// TODO
return dpts
};
};
......@@ -57,7 +57,44 @@
"principalId": "comissao",
"permission": "ALLOW",
"property": "*"
},
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW",
"property": "search"
}
],
"methods": {}
"methods": {
"search": {
"accepts": [
{
"arg": "query",
"type": "string",
"required": true,
"description": "argumento de pesquisa",
"http": {
"source": "query"
}
}
],
"returns": [
{
"arg": "resultados",
"type": "array",
"root": false,
"description": "resultados"
}
],
"description": "pesquisa um departamento",
"http": [
{
"path": "/search",
"verb": "get"
}
]
}
}
}
......@@ -26,7 +26,6 @@ async function get_user(res) {
module.exports = function(Ensalamento) {
Ensalamento.ensalar = function(cb) {
var Horario = app.models.Horario;
console.log("------------------------------------------------------")
// TODO: insert user id when create ensalamento instance
fork("/app/server/pre_ensalamento.js",[JSON.stringify({})]);
cb(null, "requisição submetida");
......
......@@ -102,5 +102,31 @@
"permission": "ALLOW"
}
],
"methods": {}
"methods": {
"search": {
"accepts": [
{
"arg": "query",
"type": "string",
"required": true,
"description": "query"
}
],
"returns": [
{
"arg": "retorno",
"type": "array",
"root": false,
"description": "retorno"
}
],
"description": "pesquisa",
"http": [
{
"path": "/search",
"verb": "get"
}
]
}
}
}
'use strict';
var app = require('../../server/server');
const async = require('async');
module.exports = function(Semestre) {
Semestre.desensala = async function(semestreId) {
var status = {"status": "ok"};
var semestre = await Semestre.findById(semestreId)
var turmas = await semestre.turmas.find() //obtem todas as turmas do semestre
for(var i=0; i<turmas.length; i++) {
var turma = turmas[i];
var horarios = await turma.horarios.find( )
for( var j=0; j<horarios.length; j++ ) {
if(horarios[j].sala)
await horarios[j].sala.destroy()
}
}
return status;
};
Semestre.deletesemestre = async function(semestreId) {
var status = {"status": "ok"};
var semestre = await Semestre.findById(semestreId)
var turmas = await semestre.turmas.find() //obtem todas as turmas do semestre
// itera a lista de semestre, removendo os horarios e a turma
for(var i=0; i<turmas.length; i++) {
var turma = turmas[i];
var horarios = await turma.horarios.find( )
for( var j=0; j<horarios.length; j++ )
await horarios[j].destroy( )
await turma.horarios.destroyAll()
turma.destroy()
}
// remove o arquivo
fileupload = await semestre.fileUploads.get( )
fileupload.destroy( )
semestre.destroy()
return status;
};
};
......@@ -33,6 +33,79 @@
"foreignKey": "fileuploadId"
}
},
"acls": [],
"methods": {}
"acls": [
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "DENY",
"property": "deletesemestre"
},
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW",
"property": "deletesemestre"
},
{
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "comissao",
"permission": "ALLOW",
"property": "deletesemestre"
}
],
"methods": {
"deletesemestre": {
"accepts": [
{
"arg": "semestreId",
"type": "string",
"required": true,
"description": "id do semestre"
}
],
"returns": [
{
"arg": "status",
"type": "object",
"root": false,
"description": "status da remocao"
}
],
"description": "remove um semestre e todas turmas e horarios que estão relacionado ao semestre",
"http": [
{
"path": "/deletesemestre",
"verb": "delete"
}
]
},
"desensala": {
"accepts": [
{
"arg": "semestreId",
"type": "string",
"required": true,
"description": "id do semestre"
}
],
"returns": [
{
"arg": "status",
"type": "object",
"root": false,
"description": "status do retorno"
}
],
"description": "desenla um semestre, removendo a relação de horario salas para todas turmas.",
"http": [
{
"path": "/desensala",
"verb": "get"
}
]
}
}
}
......@@ -35,13 +35,38 @@
"principalId": "$everyone",
"permission": "DENY",
"property": "*"
},
{
"principalType": "ROLE",
"principalId": "secretario_setor",
"permission": "ALLOW",
"property": "*"
},
{
"principalType": "ROLE",
"principalId": "admin",
"permission": "ALLOW",
"property": "*"
},
{
"principalType": "ROLE",
"principalId": "admin",
"principalId": "comissao",
"permission": "ALLOW",
"property": "*"
}
},
{
"principalType": "ROLE",
"principalId": "secretario_dpto",
"permission": "ALLOW",
"property": "*"
},
{
"principalType": "ROLE",
"principalId": "secretario_curso",
"permission": "ALLOW",
"property": "*"
}
],
"methods": {
"prototype.setRole": {
......
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