Advertisement
Guest User

Untitled

a guest
Sep 27th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. exports.pedido = function (req,res){
  2. var currentUser = req.session.user;
  3. if (currentUser){
  4. var query_restaurante = new Parse.Query(Restaurante),
  5. query_historial = new Parse.Query(Historial),
  6. query_ordenes = new Parse.Query(Orden);
  7. var restaurante;
  8. query_restaurante.include("encargado");
  9. query_restaurante.equalTo("encargado", {__type: "Pointer",className: "_User",objectId: currentUser.objectId});
  10. query_restaurante.first().then(function(restaurante_encontrado){
  11. restaurante = restaurante_encontrado;
  12. query_historial.include("usuario");
  13. query_historial.include("orden");
  14. query_historial.equalTo("restaurantes", restaurante);
  15. return query_historial.find();
  16. console.log(query_historial)
  17. }).then(function(historiales){
  18. var context = {
  19. title: "Menu",
  20. restaurante: restaurante,
  21. historial: historiales,
  22. logo_restaurante: restaurante.get("logo"),
  23. rating : restaurante.get("rating"),
  24. suspender : restaurante.get("suspender"),
  25. publicidad : restaurante.get("publicidad"),
  26. };
  27. return context;
  28. }).then(function(context){
  29. res.render('pedidos',context);
  30. return res;
  31. }, function(error) {
  32. console.log("Error " + error.code + ": " + error.message);
  33. res.redirect('/');
  34. });
  35. }else{
  36. res.redirect('/');
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement