feat: cart
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
from django.views.generic import TemplateView
|
||||
from shop.filters import ProductFilter
|
||||
from shop.models import Product
|
||||
from web.mixins import FilteredQuerysetMixin, PaginatedQuerysetMixin, CartMixin
|
||||
|
||||
|
||||
class ListProducts(TemplateView, FilteredQuerysetMixin, PaginatedQuerysetMixin):
|
||||
template_name = "web/list_products.html"
|
||||
queryset = Product.objects.all()
|
||||
filter_class = ProductFilter
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
qs = self.get_queryset()
|
||||
page = self.get_paginated_queryset(qs)
|
||||
|
||||
return {
|
||||
"page": page,
|
||||
"has_next_page": page.has_next(),
|
||||
"has_previous_page": page.has_previous(),
|
||||
}
|
||||
|
||||
|
||||
class CartDropdown(TemplateView, CartMixin):
|
||||
template_name = "components/cart/cart_navbar.html"
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
cart = self.get_cart()
|
||||
|
||||
return {
|
||||
"cart": cart,
|
||||
}
|
||||
|
||||
|
||||
list_products = ListProducts.as_view()
|
||||
cart_dropdown = CartDropdown.as_view()
|
||||
Reference in New Issue
Block a user