Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.pedido = function (req,res){
- var currentUser = req.session.user;
- if (currentUser){
- var query_restaurante = new Parse.Query(Restaurante),
- query_historial = new Parse.Query(Historial),
- query_ordenes = new Parse.Query(Orden);
- var restaurante;
- query_restaurante.include("encargado");
- query_restaurante.equalTo("encargado", {__type: "Pointer",className: "_User",objectId: currentUser.objectId});
- query_restaurante.first().then(function(restaurante_encontrado){
- restaurante = restaurante_encontrado;
- query_historial.include("usuario");
- query_historial.include("orden");
- query_historial.equalTo("restaurantes", restaurante);
- return query_historial.find();
- console.log(query_historial)
- }).then(function(historiales){
- var context = {
- title: "Menu",
- restaurante: restaurante,
- historial: historiales,
- logo_restaurante: restaurante.get("logo"),
- rating : restaurante.get("rating"),
- suspender : restaurante.get("suspender"),
- publicidad : restaurante.get("publicidad"),
- };
- return context;
- }).then(function(context){
- res.render('pedidos',context);
- return res;
- }, function(error) {
- console.log("Error " + error.code + ": " + error.message);
- res.redirect('/');
- });
- }else{
- res.redirect('/');
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement