feat: added categories
This commit is contained in:
+19
-1
@@ -4,7 +4,7 @@ from django.utils.text import gettext_lazy as _
|
||||
from django.views.decorators.http import require_http_methods
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
from shop.models import CartItem, Product
|
||||
from shop.models import CartItem, Product, ProductCategory
|
||||
from web.models import WebSettings
|
||||
from web.settings import ANONYMOUS_CART_ID_COOKIE_NAME
|
||||
from web.utils import get_or_create_cart
|
||||
@@ -22,6 +22,23 @@ class IndexView(TemplateView):
|
||||
}
|
||||
|
||||
|
||||
class CategoryView(TemplateView):
|
||||
template_name = "web/index.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
settings = WebSettings.load()
|
||||
slug = kwargs.get('slug')
|
||||
category = ProductCategory.objects.get(slug=slug)
|
||||
|
||||
return {
|
||||
"title": settings.web_title,
|
||||
"web_title": settings.web_title,
|
||||
"description": settings.web_description,
|
||||
"category": category,
|
||||
"filter_by_category": True,
|
||||
}
|
||||
|
||||
|
||||
class ProductDetail(TemplateView):
|
||||
template_name = "web/product_detail.html"
|
||||
|
||||
@@ -135,5 +152,6 @@ def manifest(request, *args, **kwargs):
|
||||
|
||||
|
||||
index = IndexView.as_view()
|
||||
category_view = CategoryView.as_view()
|
||||
product_detail = ProductDetail.as_view()
|
||||
cart_detail = CartDetail.as_view()
|
||||
|
||||
Reference in New Issue
Block a user