Skip to content

Commit

Permalink
got completed
Browse files Browse the repository at this point in the history
  • Loading branch information
sunny committed Apr 19, 2021
1 parent ed4fd4a commit f4a2b47
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
Binary file modified shoppinglyx/app/__pycache__/views.cpython-37.pyc
Binary file not shown.
17 changes: 16 additions & 1 deletion shoppinglyx/app/templates/app/productdetail.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,29 @@ <h2>Product Title: {{product.title}}</h2>
<p>{{product.description}}</p> <br>
<h4>Rs {{product.discount_price}} <small class="fw-light text-decoration-line-through">Rs {{product.selling_price}}</small></h4> <br>

{% if request.user.is_authenticated %}
{% if item_already_in_cart %}
<a href="{% url 'showcart' %}" class="btn btn-warning shadow px-5 py-2 ms-4">Go to cart</a>
{% else %}
<form action="/add-to-cart" class="d-inline">
<input type="hidden" name="prod_id" value="{{product.id}}" id="prod_id">
<button type="submit" class="btn btn-primary shadow px-5 py-2">Add to cart</button>
</form>


{% endif %}
{% endif %}

{% if not request.user.is_authenticated %}
<form action="/add-to-cart" class="d-inline">
<input type="hidden" name="prod_id" value="{{product.id}}" id="prod_id">
<button type="submit" class="btn btn-primary shadow px-5 py-2">Add to cart</button>
</form>
{% endif %}


<!-- <a href="{% url 'add-to-cart' %}" class="btn btn-primary shadow px-5 py-2">Add to Cart</a> -->
<a href="{% url 'buy-now' %}" class="btn btn-danger shadow px-5 py-2 ms-4">Buy Now</a>
<a href="{% url 'showcart' %}" class="btn btn-danger shadow px-5 py-2 ms-4">Buy Now</a>
<h5 class="mt-5">Available Offers</h5>
<ul>
<li>Bank Offer 5% Unlimited Cashback on Flipkart Axis Bank Credit</li>
Expand Down
5 changes: 4 additions & 1 deletion shoppinglyx/app/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ def get(self,request):
class ProductDetailView(View):
def get(self,request,pk):
product = Product.objects.get(pk=pk)
return render(request, 'app/productdetail.html',{'product':product})
item_already_in_cart = False
if request.user.is_authenticated:
item_already_in_cart = Cart.objects.filter(Q(product=product.id) & Q(user=request.user)).exists()
return render(request, 'app/productdetail.html',{'product':product,'item_already_in_cart':item_already_in_cart})


@login_required
Expand Down
Binary file modified shoppinglyx/db.sqlite3
Binary file not shown.

0 comments on commit f4a2b47

Please sign in to comment.