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 () { ...@@ -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; var PRODUCT_IN_LIST = false;
// function for making POST request to productList in view.py // function for making POST request to productList in view.py
...@@ -258,7 +258,3 @@ $(document).ready(function () { ...@@ -258,7 +258,3 @@ $(document).ready(function () {
event.preventDefault(); event.preventDefault();
}); });
}); });
$("li.hover-me").on('mouseenter', 'li', function () {
console.log("enter!");
});
...@@ -38,43 +38,51 @@ def productList(request): ...@@ -38,43 +38,51 @@ def productList(request):
""" """
View function for home page of site. View function for home page of site.
""" """
req = dict(request.POST)
req.pop('csrfmiddlewaretoken', None)
# s = APISentinel() # 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"
# response = requests.get(url) city_name = req['city'][0]
# json = response.json() 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]
## ----------- aqui llamada a api sentinel ----------- ## ----- aqui llamada a api sentinel
## ---------- antes consultad en DB si no se tiene ya el producto ------ ## ----- antes consultar en DB si no se tiene ya el producto
## ----------- aqui llamada a api sentinel ----------- # sentinel_result = s.getProducts(area, init_date, end_date, cloud_percentage)
## simulation of 6-digit random id, this will be obtain from sentinel(?) ## 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)]) 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 = { item_data = {
'id': random_id, 'id' : random_id,
'img': '/static/images/sat_preview/sat_test.jpg', 'img' : img_preview,
'city_name': r2['city'][0], 'city_name' : city_name,
'process': r2['platform'][0], 'process' : process,
'start_date': r2['start'][0][:10], 'start_date' : init_date,
'end_date': r2['end'][0][:10], 'end_date' : end_date,
'polygon': r2['polygon'][0], 'cloud_percentage': cloud_percentage
'cloud_percentage': r2['cloudPercentage'][0]
} }
# response = requests.get(url) return JsonResponse(item_data);
# json = response.json()
# 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 render(request, 'productList.html', {}) #"catalog":json[0]})
# return HttpResponse(json.dumps(item_data, ensure_ascii=True), content_type="application/json") # return HttpResponse(json.dumps(item_data, ensure_ascii=True), content_type="application/json")
# return render(request, 'productList.html', {'item_data': item_data}) # return render(request, 'productList.html', {'item_data': item_data})
return JsonResponse(item_data);
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class SearchSubmitView(View): 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