Skip to content

Commit

Permalink
fix: Remove notification messges ❌
Browse files Browse the repository at this point in the history
  • Loading branch information
hossainchisty committed Oct 31, 2021
1 parent a78d0f7 commit 396be75
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
17 changes: 7 additions & 10 deletions cart/templates/cart/cart.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ <h2>Card List</h2>
</div>
</div>
<!-- slider Area End-->
{% if messages.success %}
{% for message in messages %}
<div class="notification is-success is-toast">{{ message }}</div>
{% endfor %}
{% else %}
{% for message in messages %}
<div class="notification is-danger is-toast">{{ message }}</div>
{% endfor %}
{% endif %}
<!--================Cart Area =================-->
{% if cart %}
<div class="container pt-4 mb-5">
Expand All @@ -46,9 +37,15 @@ <h2>Card List</h2>
{% for item in cart %}
<tr>
<td>
{% if item.product.image %}
<figure class="image is-64x64">
<img src="{{ item.product.imageURL }}">
<img src="{{ item.product.image.url }}">
</figure>
{% else %}
<figure class="image is-64x64">
<img src="{{ item.product.url }}">
</figure>
{% endif %}
</td>
<td>
<a href="">{{ item.product.title }}</a>
Expand Down
2 changes: 0 additions & 2 deletions cart/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from django.contrib import messages
from django.shortcuts import redirect, render

from .cart import Cart
Expand All @@ -13,7 +12,6 @@ def cart_list(request):

if remove_from_cart:
cart.remove(remove_from_cart)
messages.info(request, 'Product remove from cart!')
return redirect('cart:cart_list')

if change_quantity:
Expand Down
3 changes: 0 additions & 3 deletions product/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from cart.cart import Cart
from django.contrib import messages
from django.shortcuts import get_object_or_404, redirect, render

from .forms import AddToCartForm
Expand All @@ -17,9 +16,7 @@ def product_detail(request, category_slug, product_slug):

if form.is_valid():
quantity = form.cleaned_data['quantity']
print(f"Product qty: {quantity}")
cart.add(product_id=products.id, quantity=quantity, update_quantity=False)
messages.success(request, 'Product added to cart!')
return redirect('cart:cart_list')
else:
form = AddToCartForm()
Expand Down

0 comments on commit 396be75

Please sign in to comment.