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
3fb0e478
Commit
3fb0e478
authored
Feb 08, 2019
by
José Luis Uc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Agregada opción para eliminar producto desde la vista de purchase
parent
542e40c2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
86 additions
and
58 deletions
+86
-58
dataRetrieval.js
catalog/static/catalog/js/dataRetrieval.js
+15
-0
show_cart.html
catalog/templates/show_cart.html
+68
-56
views.py
catalog/views.py
+3
-2
No files found.
catalog/static/catalog/js/dataRetrieval.js
View file @
3fb0e478
...
@@ -119,6 +119,21 @@ function deleteProductCar(element){
...
@@ -119,6 +119,21 @@ function deleteProductCar(element){
});
});
}
}
function
deleteProductFromShoppingCart
(
id
)
{
$
.
ajax
({
type
:
'POST'
,
url
:
del_prod_cartDB_url
,
data
:{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
,
'id'
:
id
},
dataType
:
'json'
,
success
:
function
(
data
)
{
location
.
reload
();
}
})
}
function
drawPolygon
(
element
)
{
function
drawPolygon
(
element
)
{
polygonList
.
forEach
(
function
(
polygon
)
{
polygonList
.
forEach
(
function
(
polygon
)
{
if
(
polygon
.
id
===
element
.
id
)
{
if
(
polygon
.
id
===
element
.
id
)
{
...
...
catalog/templates/show_cart.html
View file @
3fb0e478
...
@@ -139,6 +139,11 @@
...
@@ -139,6 +139,11 @@
<!-- Main content -->
<!-- Main content -->
<section
class=
"content"
style=
"overflow-y: auto; height: 85vh"
>
<section
class=
"content"
style=
"overflow-y: auto; height: 85vh"
>
<div
class=
"row"
>
<div
class=
"row"
>
{% if total_products == 0 %}
<div
class=
"col-md-8 col-md-offset-2"
>
<h2
class=
"text-center"
>
Your Shopping Cart is empty.
</h2>
</div>
{% else %}
<div
class=
"col-md-5 col-md-offset-2"
>
<div
class=
"col-md-5 col-md-offset-2"
>
{% for product in product_list %}
{% for product in product_list %}
<div
class=
"box box-warning"
style=
"margin-bottom: 10px"
>
<div
class=
"box box-warning"
style=
"margin-bottom: 10px"
>
...
@@ -149,6 +154,9 @@
...
@@ -149,6 +154,9 @@
<button
type=
"button"
class=
"btn btn-box-tool"
data-widget=
"collapse"
>
<button
type=
"button"
class=
"btn btn-box-tool"
data-widget=
"collapse"
>
<i
class=
"fa fa-minus"
></i>
<i
class=
"fa fa-minus"
></i>
</button>
</button>
<button
type=
"button"
class=
"btn btn-box-tool"
data-toggle=
"tooltip"
data-original-title=
"Delete"
onclick=
"deleteProductFromShoppingCart({{ product.id }})"
>
<i
class=
"fa fa-trash"
></i>
</button>
</div>
</div>
</div>
</div>
<div
class=
"box-body"
>
<div
class=
"box-body"
>
...
@@ -201,6 +209,7 @@
...
@@ -201,6 +209,7 @@
</div>
</div>
</div>
</div>
</div>
</div>
{% endif %}
</div>
</div>
</section>
</section>
<!-- /.content -->
<!-- /.content -->
...
@@ -255,4 +264,7 @@
...
@@ -255,4 +264,7 @@
{% endblock %}
{% endblock %}
{% block scripts %}
{% block scripts %}
<!-- page script -->
<!-- page script -->
<script>
var
del_prod_cartDB_url
=
"{% url 'del-cart-rqst' %}"
;
</script>
{% endblock %}
{% endblock %}
catalog/views.py
View file @
3fb0e478
...
@@ -532,7 +532,7 @@ def showCart(request):
...
@@ -532,7 +532,7 @@ def showCart(request):
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
user
=
User
.
objects
.
get
(
id
=
request
.
user
.
id
)
prod_list
=
[]
prod_list
=
[]
product_list
=
Purchase
.
objects
.
values
(
'user'
,
'productList'
,
'purchased'
,
'price'
,
'aggreg_date'
)
.
filter
(
user
=
user
,
purchased
=
0
)
product_list
=
Purchase
.
objects
.
values
(
'user'
,
'productList'
,
'purchased'
,
'price'
,
'aggreg_date'
,
'id'
)
.
filter
(
user
=
user
,
purchased
=
0
)
total_price
=
0
total_price
=
0
total_products
=
0
total_products
=
0
...
@@ -542,7 +542,8 @@ def showCart(request):
...
@@ -542,7 +542,8 @@ def showCart(request):
'purchased'
:
products
[
'purchased'
],
'purchased'
:
products
[
'purchased'
],
'price'
:
products
[
'price'
],
'price'
:
products
[
'price'
],
'aggreg_date'
:
products
[
'aggreg_date'
],
'aggreg_date'
:
products
[
'aggreg_date'
],
'catalog'
:
product
'catalog'
:
product
,
'id'
:
products
[
'id'
]
})
})
total_price
+=
products
[
'price'
]
total_price
+=
products
[
'price'
]
total_products
+=
1
total_products
+=
1
...
...
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