Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
GeoInt_SIDT
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Mario Chirinos Colunga
GeoInt_SIDT
Commits
b0ea183d
Commit
b0ea183d
authored
Feb 06, 2019
by
José Luis Uc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Agregada vista de purchase
parent
e72f36a7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
73 additions
and
51 deletions
+73
-51
base_top.html
catalog/templates/base_top.html
+16
-2
show_cart.html
catalog/templates/show_cart.html
+40
-48
views.py
catalog/views.py
+17
-1
No files found.
catalog/templates/base_top.html
View file @
b0ea183d
...
...
@@ -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>
...
...
catalog/templates/show_cart.html
View file @
b0ea183d
...
...
@@ -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"
>
<div
class=
"box-header with-border"
>
<h3
class=
"box-title"
>
Products
</h3>
</div>
<div
class=
"box-body"
>
<ul
class=
"products-list product-list-in-box"
>
<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"
>
</div>
<div
class=
"product-info"
>
<span
class=
"product-title"
>
Product 2
<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>
</ul>
{% for product in product_list %}
<div
class=
"box box-warning"
style=
"margin-bottom: 10px"
>
<div
class=
"box-header with-border"
>
<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=
"data:image/jpeg;base64, {{ catalog.info.img }}"
>
</div>
<div
class=
"product-info"
>
<span
class=
"product-title"
>
{{ catalog.info.identifier }}
</span>
<span
class=
"product-description"
>
{{ catalog.info.instrumentname }}
</span>
</div>
</li>
{% endfor %}
</ul>
</div>
</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>
</tr>
<tr>
<th>
Tax (9.3%)
</th>
<td>
$10.64
</td>
<th>
Total products:
</th>
<td>
{{ total_products }}
</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>
</t
body
>
</t
foot
>
</table>
</div>
</div>
...
...
catalog/views.py
View file @
b0ea183d
...
...
@@ -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
return
render
(
request
,
'show_cart.html'
,
{})
\ No newline at end of file
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'
,
{
'product_list'
:
prod_list
,
'total_price'
:
total_price
,
'total_products'
:
total_products
})
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment