def save(request): """Save the product into favorite.""" if request.method == "POST": data = request.POST ProductManager.save_product(request, data) favs = ProductManager.get_fav(request) return render(request, "pages/myfood.html", {"favorites": favs}) else: raise Http404
def save(request): """Save the product into favorite.""" if request.method == "POST": data = request.POST if not request.user.is_authenticated: cart = FavoriteCart(request) cart.add({ "product": data["product-searched-id"], "substitute": data["substitute-searched-id"], "user": "******", }) return redirect_to_login(request, "pages/myfood.html", login_url="/accounts/login/") ProductManager.save_product(request, data) favs = ProductManager.get_fav(request) return render(request, "pages/myfood.html", {"favorites": favs}) else: raise Http404
def fav(request): """Display favorites saved by user.""" favs = ProductManager.get_fav(request) return render(request, "pages/myfood.html", {"favorites": favs})