Commit ad233d58 authored by Renán Sosa Guillen's avatar Renán Sosa Guillen

update

parent 9fbd2a99
......@@ -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()
......
......@@ -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 en map.html
// city request to DB
// variable req_url in 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();
// petición de producto a base de datos
// variable prod_req_url en map.html
// product request to DB
// variable prod_req_url in 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 () {
});
// agrega producto al carrito
// adds 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 en map.html
// request for saving product in cart DB
// variable prod_cart_url in 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 en map.html
// request to DB for showing the products in cart
// variable prod_from_cartDB_url in 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
});
......@@ -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):
......
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