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

productList view

parent ae16b9ef
......@@ -180,7 +180,7 @@ $(document).ready(function () {
}
});
var productListGlobe = []; // this array represent DB where products will be storaged
var productListGlobe = []; // this array represent DB where products will be stored
var PRODUCT_IN_LIST = false;
// function for making POST request to productList in view.py
......@@ -258,7 +258,3 @@ $(document).ready(function () {
event.preventDefault();
});
});
$("li.hover-me").on('mouseenter', 'li', function () {
console.log("enter!");
});
......@@ -38,43 +38,51 @@ def productList(request):
"""
View function for home page of site.
"""
req = dict(request.POST)
req.pop('csrfmiddlewaretoken', None)
# s = APISentinel()
# s.getProducts()
r2 = dict(request.POST)
r2.pop('csrfmiddlewaretoken', None)
# print("R2: ", r2.keys());
# url = 'https://api.daac.asf.alaska.edu/services/search/param?'+urlencode(r2, 'utf-8')+"&output=JSON"
city_name = req['city'][0]
process = req['platform'][0]
area = req['polygon'][0]
init_date = req['start'][0][:10]
end_date = req['end'][0][:10]
cloud_percentage = req['cloudPercentage'][0]
# response = requests.get(url)
# json = response.json()
## ----------- aqui llamada a api sentinel -----------
## ---------- antes consultad en DB si no se tiene ya el producto ------
## ----------- aqui llamada a api sentinel -----------
## ----- aqui llamada a api sentinel
## ----- antes consultar en DB si no se tiene ya el producto
# sentinel_result = s.getProducts(area, init_date, end_date, cloud_percentage)
## simulation of 6-digit random id, this will be obtain from sentinel(?)
random_id = ''.join(["%s" % random.randint(0, 9) for i in range(0, 6)])
## path from image preview storage location
img_preview = '/static/images/sat_preview/sat_test.jpg'
item_data = {
'id': random_id,
'img': '/static/images/sat_preview/sat_test.jpg',
'city_name': r2['city'][0],
'process': r2['platform'][0],
'start_date': r2['start'][0][:10],
'end_date': r2['end'][0][:10],
'polygon': r2['polygon'][0],
'cloud_percentage': r2['cloudPercentage'][0]
'id' : random_id,
'img' : img_preview,
'city_name' : city_name,
'process' : process,
'start_date' : init_date,
'end_date' : end_date,
'cloud_percentage': cloud_percentage
}
# response = requests.get(url)
# json = response.json()
return JsonResponse(item_data);
# r2 = dict(request.POST)
# r2.pop('csrfmiddlewaretoken', None)
# print("R2: ", r2.keys());
# url = 'https://api.daac.asf.alaska.edu/services/search/param?'+urlencode(r2, 'utf-8')+"&output=JSON"
# response = requests.get(url)
# json = response.json()
# return render(request, 'productList.html', {}) #"catalog":json[0]})
# return HttpResponse(json.dumps(item_data, ensure_ascii=True), content_type="application/json")
# return render(request, 'productList.html', {'item_data': item_data})
return JsonResponse(item_data);
#-------------------------------------------------------------------------------
class SearchSubmitView(View):
......
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