fix: changed like button
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<svg
|
||||
class="w-5 h-5 -ms-2 me-2"
|
||||
class="w-5 h-5 -ms-2"
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
|
||||
|
Before Width: | Height: | Size: 450 B After Width: | Height: | Size: 445 B |
@@ -0,0 +1,17 @@
|
||||
<svg
|
||||
class="w-5 h-5 -ms-2"
|
||||
aria-hidden="true"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="24"
|
||||
height="24"
|
||||
fill="red"
|
||||
viewBox="0 0 24 24"
|
||||
>
|
||||
<path
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
stroke-width="0"
|
||||
d="M12.01 6.001C6.5 1 1 8 5.782 13.001L12.011 20l6.23-7C23 8 17.5 1 12.01 6.002Z"
|
||||
/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 444 B |
@@ -1,4 +1,4 @@
|
||||
<svg class="me-1.5 h-5 w-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"
|
||||
<svg class="h-5 w-5" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"
|
||||
viewBox="0 0 24 24">
|
||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||
d="M6 18 17.94 6M18 18 6.06 6"/>
|
||||
|
||||
|
Before Width: | Height: | Size: 288 B After Width: | Height: | Size: 281 B |
@@ -1,20 +1,20 @@
|
||||
{% load i18n %}
|
||||
{% if is_wishlisted %}
|
||||
<form action="" hx-post="{% url 'web:delete_from_wishlist' pk=product.pk %}" hx-swap="none">
|
||||
<form action="" hx-post="{% url 'web:delete_from_wishlist' pk=product.pk %}" hx-swap="none">
|
||||
<input type="hidden" name="product" value="{{ product.pk }}">
|
||||
{% csrf_token %}
|
||||
<button class="flex items-center justify-center py-2.5 px-5 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-primary-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">
|
||||
{% include 'components/icons/x.svg' %}
|
||||
{% translate 'Quitar de la lista de deseados' %}
|
||||
<button
|
||||
class="flex items-center justify-center rounded-full px-1.5 py-2 text-l font-medium text-gray-900 focus:outline-none bg-white border border-gray-200 hover:bg-gray-100 hover:text-primary-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">
|
||||
{% include 'components/icons/liked.svg' %}
|
||||
</button>
|
||||
</form>
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="" hx-post="{% url 'web:add_to_wishlist' %}" hx-swap="none">
|
||||
<form action="" hx-post="{% url 'web:add_to_wishlist' %}" hx-swap="none">
|
||||
<input type="hidden" name="product" value="{{ product.pk }}">
|
||||
{% csrf_token %}
|
||||
<button class="flex items-center justify-center py-2.5 px-5 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-primary-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">
|
||||
<button
|
||||
class="flex items-center justify-center rounded-full px-1.5 py-2 text-l font-medium text-gray-900 focus:outline-none bg-white border border-gray-200 hover:bg-gray-100 hover:text-primary-700 focus:z-10 focus:ring-4 focus:ring-gray-100 dark:focus:ring-gray-700 dark:bg-gray-800 dark:text-gray-400 dark:border-gray-600 dark:hover:text-white dark:hover:bg-gray-700">
|
||||
{% include 'components/icons/like.svg' %}
|
||||
{% translate 'Añadir a lista de deseados' %}
|
||||
</button>
|
||||
</form>
|
||||
</form>
|
||||
{% endif %}
|
||||
@@ -2,9 +2,8 @@ from django.contrib.auth.models import User
|
||||
from django.test import TestCase
|
||||
from django.urls import reverse
|
||||
|
||||
from shop.models import Cart, CartItem, WishlistedProduct
|
||||
from shop.models import WishlistedProduct
|
||||
from shop.tests.mixins import CreateProductsMixin
|
||||
from web.settings import ANONYMOUS_CART_ID_COOKIE_NAME
|
||||
|
||||
|
||||
class TestWishlist(TestCase, CreateProductsMixin):
|
||||
@@ -47,8 +46,7 @@ class TestWishlist(TestCase, CreateProductsMixin):
|
||||
|
||||
def test_logged_user_delete_wishlisted_product(self):
|
||||
wishlisted = WishlistedProduct.objects.create(
|
||||
user=self.user,
|
||||
product=self.product,
|
||||
user=self.user, product=self.product
|
||||
)
|
||||
self.client.force_login(self.user)
|
||||
response = self.client.post(
|
||||
@@ -60,33 +58,18 @@ class TestWishlist(TestCase, CreateProductsMixin):
|
||||
).exists()
|
||||
|
||||
def test_logged_user_wishlist(self):
|
||||
WishlistedProduct.objects.create(
|
||||
user=self.user,
|
||||
product=self.product,
|
||||
)
|
||||
WishlistedProduct.objects.create(user=self.user, product=self.product)
|
||||
self.client.force_login(self.user)
|
||||
response = self.client.get(
|
||||
reverse("web:wishlist")
|
||||
)
|
||||
response = self.client.get(reverse("web:wishlist"))
|
||||
assert response.status_code == 200
|
||||
|
||||
def test_not_logged_user_wishlist(self):
|
||||
WishlistedProduct.objects.create(
|
||||
user=self.user,
|
||||
product=self.product,
|
||||
)
|
||||
response = self.client.get(
|
||||
reverse("web:wishlist")
|
||||
)
|
||||
WishlistedProduct.objects.create(user=self.user, product=self.product)
|
||||
response = self.client.get(reverse("web:wishlist"))
|
||||
assert response.status_code == 302
|
||||
|
||||
def test_list_wishlisted_products(self):
|
||||
WishlistedProduct.objects.create(
|
||||
user=self.user,
|
||||
product=self.product,
|
||||
)
|
||||
WishlistedProduct.objects.create(user=self.user, product=self.product)
|
||||
self.client.force_login(self.user)
|
||||
response = self.client.get(
|
||||
reverse("web:list_wishlisted_products")
|
||||
)
|
||||
response = self.client.get(reverse("web:list_wishlisted_products"))
|
||||
assert response.status_code == 200
|
||||
|
||||
+1
-11
@@ -1,8 +1,4 @@
|
||||
from decimal import Decimal
|
||||
|
||||
from django.db.models import Sum
|
||||
|
||||
from shop.models import Cart, CartItem
|
||||
from shop.models import Cart
|
||||
from web.settings import ANONYMOUS_CART_ID_COOKIE_NAME
|
||||
|
||||
|
||||
@@ -20,9 +16,3 @@ def get_or_create_cart(request) -> [Cart, bool]:
|
||||
cart, created = Cart.objects.get_or_create(user=request.user)
|
||||
|
||||
return cart, created
|
||||
|
||||
|
||||
def get_cart_total(cart: Cart):
|
||||
return CartItem.objects.filter(cart=cart).annotate(cart_total=Sum("total")).get(
|
||||
"cart_total"
|
||||
) or Decimal("0.00")
|
||||
|
||||
Reference in New Issue
Block a user