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
ad233d58
Commit
ad233d58
authored
Oct 11, 2018
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
9fbd2a99
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
30 deletions
+34
-30
models.py
catalog/models.py
+1
-1
dataRetrieval.js
catalog/static/js/dataRetrieval.js
+32
-29
views.py
catalog/views.py
+1
-0
No files found.
catalog/models.py
View file @
ad233d58
...
...
@@ -42,8 +42,8 @@ class Product_l2a(models.Model):
class
CartProduct
(
models
.
Model
):
user
=
models
.
ForeignKey
(
User
,
on_delete
=
models
.
CASCADE
)
aggreg_date
=
models
.
DateTimeField
(
auto_now
=
True
)
## date of product aggregation
uuid
=
models
.
CharField
(
max_length
=
50
)
aggreg_date
=
models
.
DateTimeField
(
auto_now
=
True
)
## date of product aggregation
info
=
models
.
TextField
(
null
=
True
)
purchased
=
models
.
NullBooleanField
()
...
...
catalog/static/js/dataRetrieval.js
View file @
ad233d58
...
...
@@ -14,8 +14,8 @@ var polygonList;
var
makeRequest
=
function
(
value
)
{
var
pol_element
=
document
.
getElementById
(
'polygon-list'
);
//
petición de municipios a base de datos
// variable req_url
e
n map.html
//
city request to DB
// variable req_url
i
n map.html
$
.
ajax
({
type
:
"POST"
,
url
:
req_url
,
...
...
@@ -112,6 +112,7 @@ $("#id_polygon").on('keyup', function (e) {
});
// this function cleans list of available products
function
erase_product_list_globe
()
{
prevfeature
=
null
;
var
pol_element
=
document
.
getElementById
(
'product-list-globe'
);
...
...
@@ -121,6 +122,7 @@ function erase_product_list_globe() {
}
// this function cleans list of available products by ID
function
erase_product_list_globe_by_id
(
element_id
)
{
var
$div_element
=
$
(
'div#'
+
element_id
+
"-div"
);
var
$li_element
=
$
(
'li#'
+
element_id
+
"-li"
);
...
...
@@ -129,6 +131,15 @@ function erase_product_list_globe_by_id(element_id) {
}
// this function cleans list of products in cart
function
erase_product_list_cart
()
{
var
item_element
=
document
.
getElementById
(
'product-list-cart'
);
while
(
item_element
.
firstChild
)
{
item_element
.
removeChild
(
item_element
.
firstChild
);
}
}
var
prevfeature
=
null
;
function
drawApiResponse
(
element
)
{
var
list_globe
=
document
.
getElementById
(
'product-list-globe'
).
children
;
...
...
@@ -251,8 +262,8 @@ $(document).ready(function () {
erase_product_list_globe
();
var
submit_data
=
$
(
'#product-form'
).
serialize
();
// p
etición de producto a base de datos
// variable prod_req_url
e
n map.html
// p
roduct request to DB
// variable prod_req_url
i
n map.html
$
.
ajax
({
type
:
"POST"
,
url
:
prod_req_url
,
...
...
@@ -269,7 +280,8 @@ $(document).ready(function () {
console
.
log
(
"DEFS: ahora crea producto"
);
data
.
catalog
.
forEach
(
function
(
data
)
{
// petición de imagen a webservice
// image request to webservice
// variable img_req_url in map.html
$
.
ajax
({
type
:
"GET"
,
url
:
img_req_url
,
...
...
@@ -316,7 +328,7 @@ $(document).ready(function () {
});
// a
grega producto al carrito
// a
dds product to cart
$
(
'#product-to-cart-form'
).
submit
(
function
(
event
)
{
event
.
preventDefault
();
var
ul_element
=
document
.
getElementById
(
'product-list-globe'
);
...
...
@@ -352,8 +364,8 @@ $(document).ready(function () {
});
if
(
cartProductList
.
length
>
0
)
{
// request
para guardado de producto en carrito
// variable prod_cart_url
e
n map.html
// request
for saving product in cart DB
// variable prod_cart_url
i
n map.html
$
.
ajax
({
type
:
'POST'
,
url
:
prod_cart_url
,
...
...
@@ -364,26 +376,15 @@ $(document).ready(function () {
success
:
function
()
{
cartProductList
=
[];
productUUIDListCart
.
push
.
apply
(
productUUIDListCart
,
productsToObtain
);
// PRODUCT_COUNTER += 1; // this variable counts the number of products in shopping cart
// PRODUCT_COUNTER_STR = PRODUCT_COUNTER.toString();
// var temp_1 = document.querySelector('#product_cart_1');
// var prod_id = temp_1.content.querySelectorAll('ul')[1].id + "-" + PRODUCT_COUNTER_STR;
// // filling template
// temp_1.content.querySelector('span').textContent = "Product " + PRODUCT_COUNTER_STR;
// temp_1.content.querySelectorAll('ul')[1].id = prod_id;
// var clone_1 = document.importNode(temp_1.content, true);
// document.querySelector('#product-list-cart').appendChild(clone_1);
if
(
!
IS_PRODUCT_CONTAINER
)
{
// building product container
createProductContainer
();
IS_PRODUCT_CONTAINER
=
true
;
IS_PRODUCT_CONTAINER
=
true
;
// this flag is set to false when products are purchased
}
// TODO : return IS_PRODUCT_CONTAINER to 'false' in some point
// request
a DB para mostrar los productos en el carrito
// variable prod_from_cartDB_url
e
n map.html
// request
to DB for showing the products in cart
// variable prod_from_cartDB_url
i
n map.html
$
.
ajax
({
type
:
'POST'
,
url
:
prod_from_cartDB_url
,
...
...
@@ -409,7 +410,6 @@ $(document).ready(function () {
var
clone_2
=
document
.
importNode
(
temp_2
.
content
,
true
);
document
.
querySelector
(
'#product-list-cart-items'
).
appendChild
(
clone_2
);
// document.querySelector('#' + prod_id).appendChild(clone_2);
});
}
});
...
...
@@ -425,7 +425,7 @@ $(document).ready(function () {
});
//
compra de producto(s) que está(n) en el carrito
//
purchasing products in cart
$
(
'#purchased-product-form'
).
submit
(
function
(
event
)
{
event
.
preventDefault
();
var
ul_element
=
document
.
getElementById
(
'product-list-cart'
);
...
...
@@ -441,6 +441,7 @@ $(document).ready(function () {
});
// L1C product download request
// variable purch_prod_url in map.html
$
.
ajax
({
type
:
"POST"
,
url
:
purch_prod_url
,
...
...
@@ -450,6 +451,10 @@ $(document).ready(function () {
},
dataType
:
'json'
});
erase_product_list_cart
();
IS_PRODUCT_CONTAINER
=
false
;
productUUIDListCart
=
[];
}
else
{
mssgModal
({
title
:
"No products available!"
,
...
...
@@ -457,6 +462,4 @@ $(document).ready(function () {
});
}
});
// TODO: Clean productUUIDListCart array after purchased is done
});
catalog/views.py
View file @
ad233d58
...
...
@@ -217,6 +217,7 @@ def purchaseProduct(request):
return
HttpResponse
(
status
=
204
)
## TODO: Implement a webservice in server for downloading those non-existing L1C products. ##
## TODO: Add product L1C to Cart DB after product download. ##
#-------------------------------------------------------------------------------
def
L2ASCL_data
(
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