fix: changed like button
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<svg
|
<svg
|
||||||
class="w-5 h-5 -ms-2 me-2"
|
class="w-5 h-5 -ms-2"
|
||||||
aria-hidden="true"
|
aria-hidden="true"
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="24"
|
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">
|
viewBox="0 0 24 24">
|
||||||
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
|
||||||
d="M6 18 17.94 6M18 18 6.06 6"/>
|
d="M6 18 17.94 6M18 18 6.06 6"/>
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 288 B After Width: | Height: | Size: 281 B |
@@ -3,18 +3,18 @@
|
|||||||
<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 }}">
|
<input type="hidden" name="product" value="{{ product.pk }}">
|
||||||
{% csrf_token %}
|
{% 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
|
||||||
{% include 'components/icons/x.svg' %}
|
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">
|
||||||
{% translate 'Quitar de la lista de deseados' %}
|
{% include 'components/icons/liked.svg' %}
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
{% else %}
|
{% 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 }}">
|
<input type="hidden" name="product" value="{{ product.pk }}">
|
||||||
{% csrf_token %}
|
{% 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' %}
|
{% include 'components/icons/like.svg' %}
|
||||||
{% translate 'Añadir a lista de deseados' %}
|
|
||||||
</button>
|
</button>
|
||||||
</form>
|
</form>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -2,9 +2,8 @@ from django.contrib.auth.models import User
|
|||||||
from django.test import TestCase
|
from django.test import TestCase
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
from shop.models import Cart, CartItem, WishlistedProduct
|
from shop.models import WishlistedProduct
|
||||||
from shop.tests.mixins import CreateProductsMixin
|
from shop.tests.mixins import CreateProductsMixin
|
||||||
from web.settings import ANONYMOUS_CART_ID_COOKIE_NAME
|
|
||||||
|
|
||||||
|
|
||||||
class TestWishlist(TestCase, CreateProductsMixin):
|
class TestWishlist(TestCase, CreateProductsMixin):
|
||||||
@@ -47,8 +46,7 @@ class TestWishlist(TestCase, CreateProductsMixin):
|
|||||||
|
|
||||||
def test_logged_user_delete_wishlisted_product(self):
|
def test_logged_user_delete_wishlisted_product(self):
|
||||||
wishlisted = WishlistedProduct.objects.create(
|
wishlisted = WishlistedProduct.objects.create(
|
||||||
user=self.user,
|
user=self.user, product=self.product
|
||||||
product=self.product,
|
|
||||||
)
|
)
|
||||||
self.client.force_login(self.user)
|
self.client.force_login(self.user)
|
||||||
response = self.client.post(
|
response = self.client.post(
|
||||||
@@ -60,33 +58,18 @@ class TestWishlist(TestCase, CreateProductsMixin):
|
|||||||
).exists()
|
).exists()
|
||||||
|
|
||||||
def test_logged_user_wishlist(self):
|
def test_logged_user_wishlist(self):
|
||||||
WishlistedProduct.objects.create(
|
WishlistedProduct.objects.create(user=self.user, product=self.product)
|
||||||
user=self.user,
|
|
||||||
product=self.product,
|
|
||||||
)
|
|
||||||
self.client.force_login(self.user)
|
self.client.force_login(self.user)
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("web:wishlist"))
|
||||||
reverse("web:wishlist")
|
|
||||||
)
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
||||||
def test_not_logged_user_wishlist(self):
|
def test_not_logged_user_wishlist(self):
|
||||||
WishlistedProduct.objects.create(
|
WishlistedProduct.objects.create(user=self.user, product=self.product)
|
||||||
user=self.user,
|
response = self.client.get(reverse("web:wishlist"))
|
||||||
product=self.product,
|
|
||||||
)
|
|
||||||
response = self.client.get(
|
|
||||||
reverse("web:wishlist")
|
|
||||||
)
|
|
||||||
assert response.status_code == 302
|
assert response.status_code == 302
|
||||||
|
|
||||||
def test_list_wishlisted_products(self):
|
def test_list_wishlisted_products(self):
|
||||||
WishlistedProduct.objects.create(
|
WishlistedProduct.objects.create(user=self.user, product=self.product)
|
||||||
user=self.user,
|
|
||||||
product=self.product,
|
|
||||||
)
|
|
||||||
self.client.force_login(self.user)
|
self.client.force_login(self.user)
|
||||||
response = self.client.get(
|
response = self.client.get(reverse("web:list_wishlisted_products"))
|
||||||
reverse("web:list_wishlisted_products")
|
|
||||||
)
|
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|||||||
+1
-11
@@ -1,8 +1,4 @@
|
|||||||
from decimal import Decimal
|
from shop.models import Cart
|
||||||
|
|
||||||
from django.db.models import Sum
|
|
||||||
|
|
||||||
from shop.models import Cart, CartItem
|
|
||||||
from web.settings import ANONYMOUS_CART_ID_COOKIE_NAME
|
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)
|
cart, created = Cart.objects.get_or_create(user=request.user)
|
||||||
|
|
||||||
return cart, created
|
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