This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Данный файл нужно добавить в ваше приложение магазина | |
""" | |
from .models import Category | |
def list_categoryes(request): | |
"""Список категорий в меню""" | |
return {"menu_categoryes": Category.objects.all()} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CategoryProductVue(View): | |
"""Список товаров из категории для vue""" | |
def get(self, request): | |
return render(request, "shop/vue/list-product-vue.html") | |
def post(self, request): | |
slug = request.POST.get("slug") | |
node = Category.objects.get(slug=slug) | |
if Product.objects.filter(category__slug=slug).exists(): | |
products = Product.objects.filter(category__slug=slug) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AddCartItem(View): | |
"""Добавление товара в карзину""" | |
def check_cart(self, request): | |
if request.user.is_authenticated: | |
cart = Cart.objects.get(user=request.user, accepted=False) | |
else: | |
session_cart = request.session.get('cart') | |
if not session_cart: | |
SessionStore = import_module(settings.SESSION_ENGINE).SessionStore |
NewerOlder