feat: added tests for wishlist

This commit is contained in:
2025-01-02 11:29:45 +01:00
parent eed3905638
commit 7ef4d58ffa
9 changed files with 118 additions and 28 deletions
+6 -4
View File
@@ -1,6 +1,6 @@
from decimal import Decimal
from django.shortcuts import render, get_object_or_404
from django.shortcuts import get_object_or_404, render
from django.views.generic import TemplateView
from shop.filters import ProductFilter
@@ -76,11 +76,13 @@ def cart(request, *args, **kwargs):
class WishlistButton(TemplateView):
template_name = 'components/products/wishlist_button.html'
template_name = "components/products/wishlist_button.html"
def get_context_data(self, **kwargs):
product = get_object_or_404(Product, pk=self.kwargs.get('pk'))
is_wishlisted = WishlistedProduct.objects.filter(user=self.request.user, product=product).exists()
product = get_object_or_404(Product, pk=self.kwargs.get("pk"))
is_wishlisted = WishlistedProduct.objects.filter(
user=self.request.user, product=product
).exists()
return {
"is_wishlisted": is_wishlisted,