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
ce6d960a
Commit
ce6d960a
authored
Oct 08, 2018
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
performance improvement
parent
98e3846f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
7 deletions
+66
-7
dataRetrieval.js
catalog/static/js/dataRetrieval.js
+35
-1
map.html
catalog/templates/map.html
+6
-5
urls.py
catalog/urls.py
+2
-1
views.py
catalog/views.py
+23
-0
No files found.
catalog/static/js/dataRetrieval.js
View file @
ce6d960a
...
@@ -390,7 +390,7 @@ $(document).ready(function () {
...
@@ -390,7 +390,7 @@ $(document).ready(function () {
},
},
dataType
:
'json'
,
dataType
:
'json'
,
success
:
function
(
data
)
{
success
:
function
(
data
)
{
productUUIDListCart
=
[];
//
productUUIDListCart = [];
data
.
product_list
.
forEach
(
function
(
product
)
{
data
.
product_list
.
forEach
(
function
(
product
)
{
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
var
temp_2
=
document
.
querySelector
(
'#product_cart_2'
);
...
@@ -420,4 +420,38 @@ $(document).ready(function () {
...
@@ -420,4 +420,38 @@ $(document).ready(function () {
}
}
}
}
});
});
//compra de producto(s) que está(n) en el carrito
$
(
'#purchased-product-form'
).
submit
(
function
(
event
)
{
event
.
preventDefault
();
var
ul_element
=
document
.
getElementById
(
'product-list-cart'
);
if
(
ul_element
.
firstChild
)
{
console
.
log
(
"productUUIDListCart: "
,
productUUIDListCart
);
var
productObject
=
{};
productListGlobe
.
forEach
(
function
(
data
)
{
if
(
productUUIDListCart
.
indexOf
(
data
.
uuid
)
>
-
1
)
{
productObject
[
data
.
uuid
]
=
data
.
product
;
}
});
// L1C product download petition
$
.
ajax
({
type
:
"POST"
,
url
:
purch_prod_url
,
data
:
{
'csrfmiddlewaretoken'
:
document
.
getElementsByName
(
'csrfmiddlewaretoken'
)[
0
].
value
,
'product_objects'
:
JSON
.
stringify
(
productObject
)
},
dataType
:
'json'
});
}
else
{
mssgModal
({
title
:
"No products available!"
,
body
:
"There are no products charged in cart yet."
});
}
});
});
});
catalog/templates/map.html
View file @
ce6d960a
...
@@ -253,9 +253,10 @@
...
@@ -253,9 +253,10 @@
osmap
.
addInteraction
();
osmap
.
addInteraction
();
var
req_url
=
"{% url 'search-submit' %}"
;
// url for requesting polygon data
var
req_url
=
"{% url 'search-submit' %}"
;
// url for requesting polygon data
var
prod_req_url
=
"{% url 'productList' %}"
// url for requesting product data
var
prod_req_url
=
"{% url 'productList' %}"
;
// url for requesting product data
var
img_req_url
=
"{% url 'img-rqst' %}"
// url for requesting preview image
var
img_req_url
=
"{% url 'img-rqst' %}"
;
// url for requesting preview image
var
prod_cart_url
=
"{% url 'cart-rqst' %}"
// url for requesting product saving in cart
var
prod_cart_url
=
"{% url 'cart-rqst' %}"
;
// url for requesting product saving in cart
var
prod_from_cartDB_url
=
"{% url 'from-cart-rqst' %}"
// url for requesting product from cart table in DB
var
prod_from_cartDB_url
=
"{% url 'from-cart-rqst' %}"
;
// url for requesting product from cart table in DB
var
purch_prod_url
=
"{% url 'purch-prod-rqst' %}"
;
</script>
</script>
{% endblock %}
{% endblock %}
catalog/urls.py
View file @
ce6d960a
...
@@ -10,6 +10,7 @@ urlpatterns = [
...
@@ -10,6 +10,7 @@ urlpatterns = [
url
(
r'^searchsubmit/$'
,
views
.
SearchSubmitView
.
as_view
(),
name
=
'search-submit'
),
url
(
r'^searchsubmit/$'
,
views
.
SearchSubmitView
.
as_view
(),
name
=
'search-submit'
),
url
(
r'^imgrequest/$'
,
views
.
requestToImage
,
name
=
'img-rqst'
),
url
(
r'^imgrequest/$'
,
views
.
requestToImage
,
name
=
'img-rqst'
),
url
(
r'^cartrequest/$'
,
views
.
saveInCart
,
name
=
'cart-rqst'
),
url
(
r'^cartrequest/$'
,
views
.
saveInCart
,
name
=
'cart-rqst'
),
url
(
r'^fromcartrqst/$'
,
views
.
getFromCart
,
name
=
'from-cart-rqst'
)
url
(
r'^fromcartrqst/$'
,
views
.
getFromCart
,
name
=
'from-cart-rqst'
),
url
(
r'^purchcartrqst/$'
,
views
.
purchaseProduct
,
name
=
'purch-prod-rqst'
)
]
]
catalog/views.py
View file @
ce6d960a
...
@@ -198,6 +198,29 @@ def getFromCart(request):
...
@@ -198,6 +198,29 @@ def getFromCart(request):
return
JsonResponse
({
'product_list'
:
prod_list
})
return
JsonResponse
({
'product_list'
:
prod_list
})
#-------------------------------------------------------------------------------
def
purchaseProduct
(
request
):
"""
For now to purchase a product consists in verifying whether L1C products in cart already exist in DB.
"""
products
=
json
.
loads
(
request
.
POST
[
'product_objects'
])
orderedProducts
=
OrderedDict
()
for
p_uuid
in
products
.
keys
():
PRODUCT_EXISTS
=
Product_l1c
.
objects
.
filter
(
uuid
=
p_uuid
)
.
exists
()
if
not
PRODUCT_EXISTS
:
orderedProducts
[
p_uuid
]
=
products
[
p_uuid
]
print
orderedProducts
return
HttpResponse
(
status
=
204
)
## TODO: Implement a webservice in server for downloading those non-existing L1C products. ##
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# def purchaseProduct(request):
# def purchaseProduct(request):
# """
# """
...
...
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