Commit 46a64d23 authored by Odair M.'s avatar Odair M. Committed by Matheus Horstmann

Closes #14 resolve o problema de possível registro duplicados

parent 8eaef2de
Subproject commit ab2b14495c1592c64e958d64b3b67e3755ec3cb2
Subproject commit 0ca16e519402a63fd85c8809a1133a20ab44d99a
......@@ -15,9 +15,18 @@ module.exports = function(Disciplina) {
Disciplina.prototype.addEquivalencia = function(disciplina_eq_codigo, cb) {
var Eq = app.models.Equivalenciadisciplina;
Eq.create({"disciplina1": this.codigo, "disciplina2":disciplina_eq_codigo}, function(err, eq){
cb(err,eq);
});
Eq.find({"where":{or:[
{and:[{"disciplina1":this.codigo},{"disciplina2":disciplina_eq_codigo} ]},
{and:[{"disciplina1":disciplina_eq_codigo}, {"disciplina2":this.codigo}]}
]}},(err,obj)=>{
if(obj) return cb(true,"já existe")
Eq.create({"disciplina1": this.codigo, "disciplina2":disciplina_eq_codigo}, function(err, eq){
cb(err,eq);
});
})
};
/**
......
......@@ -36,6 +36,12 @@
"permission": "ALLOW",
"property": "*"
},
{
"principalType": "ROLE",
"principalId": "secretario_dpto",
"permission": "ALLOW",
"property": "*"
},
{
"principalType": "ROLE",
"principalId": "admin",
......
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