Commit baba5e58 authored by Vytor Calixto's avatar Vytor Calixto 👾

Separada rota de gerenciamento do upload

parent f3f197e9
......@@ -18,6 +18,7 @@ var oauth2 = require('./auth/oauth2')
var rotas = require('./routes/routes')
var admin = require('./routes/admin/admin')
var uploads = require('./routes/admin/uploads')
var materias = require('./routes/admin/materias')
var professores = require('./routes/admin/professores')
var usuarios = require('./routes/admin/usuarios')
......@@ -49,6 +50,7 @@ app.use(flash())
// Rotas da aplicação
app.use('/', rotas)
app.use('/admin', admin)
app.use('/admin/uploads', uploads)
app.use('/admin/materias', materias)
app.use('/admin/professores', professores)
app.use('/admin/usuarios', usuarios)
......
......@@ -22,19 +22,4 @@ router.get('/', function(req, res) {
})
})
router.get('/uploads', function(req, res) {
Arquivo.find({status: 'pendente'})
.populate('materia')
.populate('professor')
.populate('usuario')
.exec(function(err, arquivos) {
if(!err) {
return res.render('admin/uploads', {user: req.user , uploads: arquivos})
} else {
// TODO: redirecionar para página de erro
}
})
})
module.exports = router
var express = require('express')
var passport = require('passport')
var router = express.Router()
var libs = process.cwd() + '/libs/'
var role = require(libs + 'role')
var Usuario = require(libs + 'model/usuario')
var Arquivo = require(libs + 'model/arquivo')
var Materia = require(libs + 'model/materia')
router.use(role.isLoggedIn())
router.use(role.isModerador())
router.get('/uploads', function(req, res) {
Arquivo.find({status: 'pendente'})
.populate('materia')
.populate('professor')
.populate('usuario')
.exec(function(err, arquivos) {
if(!err) {
return res.render('admin/uploads', {user: req.user , uploads: arquivos})
} else {
// TODO: redirecionar para página de erro
}
})
})
module.exports = router
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