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

Agregada vista de purchase

parent e72f36a7
......@@ -134,7 +134,7 @@
<!-- /.tab-pane -->
<!-- Settings tab content -->
<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 %}
<div class="container">
<div class="sidebar-title">
......@@ -148,7 +148,21 @@
</div>
<!-- this ul element is filled with data -->
<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>
<!-- /.tab-pane -->
</div>
......
......@@ -164,46 +164,41 @@
<div class="text-center"><h1>Shopping Cart</h1></div>
<!-- Content Wrapper. Contains page content -->
<!-- Main content -->
<section class="content">
<section class="content" style="overflow-y: auto; height: 85vh">
<div class="row">
<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">
<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 class="box-body">
<ul class="products-list product-list-in-box">
{% for catalog in product.catalog %}
<li class="item">
<div class="product-img">
<img src="https://via.placeholder.com/150">
</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">
<img src="data:image/jpeg;base64, {{ catalog.info.img }}">
</div>
<div class="product-info">
<span class="product-title">
Product 2
<span class="label label-info pull-right">$5</span>
{{ catalog.info.identifier }}
</span>
<span class="product-description">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
{{ catalog.info.instrumentname }}
</span>
</div>
</li>
{% endfor %}
</ul>
</div>
</div>
{% endfor %}
</div>
<div class="col-md-3">
<div class="box box-warning">
......@@ -215,22 +210,19 @@
<table class="table">
<tbody>
<tr>
<th>Subtotal:</th>
<td>$250.30</td>
<th>Total products:</th>
<td>{{ total_products }}</td>
</tr>
<tr>
<th>Tax (9.3%)</th>
<td>$10.64</td>
</tr>
<tr>
<th>Shipping:</th>
<td>$5.80</td>
<th>Total price:</th>
<td>${{ total_price }}</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Total:</th>
<td>$265.24</td>
<td><button type="button" name="pay" id="pay" class="btn btn-primary">Pay</button></td>
</tr>
</tbody>
</tfoot>
</table>
</div>
</div>
......
......@@ -376,5 +376,21 @@ def purchaseProduct(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', {})
\ No newline at end of file
return render(request, 'show_cart.html', {'product_list': prod_list, 'total_price': total_price, 'total_products': total_products})
\ 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