Commit b0ea183d authored by José Luis Uc's avatar José Luis Uc

Agregada vista de purchase

parent e72f36a7
...@@ -134,7 +134,7 @@ ...@@ -134,7 +134,7 @@
<!-- /.tab-pane --> <!-- /.tab-pane -->
<!-- Settings tab content --> <!-- Settings tab content -->
<div class="tab-pane" id="control-sidebar-settings-tab"> <div class="tab-pane" id="control-sidebar-settings-tab">
<form id='purchased-product-form' role="form" method="post"> {% comment %}<form id='purchased-product-form' role="form" method="post">
{% csrf_token %} {% csrf_token %}
<div class="container"> <div class="container">
<div class="sidebar-title"> <div class="sidebar-title">
...@@ -148,7 +148,21 @@ ...@@ -148,7 +148,21 @@
</div> </div>
<!-- this ul element is filled with data --> <!-- this ul element is filled with data -->
<ul id="product-list-cart" class="sidebar-menu" data-widget="tree"></ul> <ul id="product-list-cart" class="sidebar-menu" data-widget="tree"></ul>
</form> </form>{% endcomment %}
<div class="container">
<div class="sidebar-title">
<h3><b>My cart</b></h3>
</div>
<div class="sidebar-button">
{% comment %}<button type="submit" name="search" id="purchase" class="btn btn-primary">
Purchase
</button>{% endcomment %}
{% comment %}<a href="cart" id="purchase" class="btn btn-primary">Purchase</a>{% endcomment %}
<button onclick="location.href='cart'" id="purchase" class="btn btn-primary">Purchase</button>
</div>
</div>
<!-- this ul element is filled with data -->
<ul id="product-list-cart" class="sidebar-menu" data-widget="tree"></ul>
</div> </div>
<!-- /.tab-pane --> <!-- /.tab-pane -->
</div> </div>
......
...@@ -164,46 +164,41 @@ ...@@ -164,46 +164,41 @@
<div class="text-center"><h1>Shopping Cart</h1></div> <div class="text-center"><h1>Shopping Cart</h1></div>
<!-- Content Wrapper. Contains page content --> <!-- Content Wrapper. Contains page content -->
<!-- Main content --> <!-- Main content -->
<section class="content"> <section class="content" style="overflow-y: auto; height: 85vh">
<div class="row"> <div class="row">
<div class="col-md-5 col-md-offset-2"> <div class="col-md-5 col-md-offset-2">
<div class="box box-warning"> {% for product in product_list %}
<div class="box box-warning" style="margin-bottom: 10px">
<div class="box-header with-border"> <div class="box-header with-border">
<h3 class="box-title">Products</h3> <h3 class="box-title">Product {{ product.aggreg_date }}</h3>
<div class="box-tools pull-right">
<span class="badge bg-green">Price ${{ product.price }}</span>
<button type="button" class="btn btn-box-tool" data-widget="collapse">
<i class="fa fa-minus"></i>
</button>
</div>
</div> </div>
<div class="box-body"> <div class="box-body">
<ul class="products-list product-list-in-box"> <ul class="products-list product-list-in-box">
{% for catalog in product.catalog %}
<li class="item"> <li class="item">
<div class="product-img"> <div class="product-img">
<img src="https://via.placeholder.com/150"> <img src="data:image/jpeg;base64, {{ catalog.info.img }}">
</div>
<div class="product-info">
<span class="product-title">
Product 1
<span class="label label-info pull-right">$5</span>
</span>
<span class="product-description">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</span>
</div>
</li>
<li class="item">
<div class="product-img">
<img src="https://via.placeholder.com/150">
</div> </div>
<div class="product-info"> <div class="product-info">
<span class="product-title"> <span class="product-title">
Product 2 {{ catalog.info.identifier }}
<span class="label label-info pull-right">$5</span>
</span> </span>
<span class="product-description"> <span class="product-description">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. {{ catalog.info.instrumentname }}
</span> </span>
</div> </div>
</li> </li>
{% endfor %}
</ul> </ul>
</div> </div>
</div> </div>
{% endfor %}
</div> </div>
<div class="col-md-3"> <div class="col-md-3">
<div class="box box-warning"> <div class="box box-warning">
...@@ -215,22 +210,19 @@ ...@@ -215,22 +210,19 @@
<table class="table"> <table class="table">
<tbody> <tbody>
<tr> <tr>
<th>Subtotal:</th> <th>Total products:</th>
<td>$250.30</td> <td>{{ total_products }}</td>
</tr> </tr>
<tr> <tr>
<th>Tax (9.3%)</th> <th>Total price:</th>
<td>$10.64</td> <td>${{ total_price }}</td>
</tr>
<tr>
<th>Shipping:</th>
<td>$5.80</td>
</tr> </tr>
</tbody>
<tfoot>
<tr> <tr>
<th>Total:</th> <td><button type="button" name="pay" id="pay" class="btn btn-primary">Pay</button></td>
<td>$265.24</td>
</tr> </tr>
</tbody> </tfoot>
</table> </table>
</div> </div>
</div> </div>
......
...@@ -376,5 +376,21 @@ def purchaseProduct(request): ...@@ -376,5 +376,21 @@ def purchaseProduct(request):
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
def showCart(request): def showCart(request):
user = User.objects.get(id=request.user.id)
prod_list = []
product_list = Purchase.objects.values('user', 'productList', 'purchased', 'price', 'aggreg_date').filter(user=user, purchased=0)
total_price = 0
total_products = 0
for products in product_list:
product = json.loads(products['productList'])
prod_list.append({
'purchased': products['purchased'],
'price': products['price'],
'aggreg_date': products['aggreg_date'],
'catalog': product
})
total_price += products['price']
total_products += 1
return render(request, 'show_cart.html', {}) return render(request, 'show_cart.html', {'product_list': prod_list, 'total_price': total_price, 'total_products': total_products})
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment