Commit 7a8e1ccf authored by Renán Sosa Guillen's avatar Renán Sosa Guillen

prueba

parent a46e40a0
...@@ -72,7 +72,7 @@ $(document).ready(function () { ...@@ -72,7 +72,7 @@ $(document).ready(function () {
// dataList.appendChild(option); // dataList.appendChild(option);
// }); // });
$('#ajax-input').autocomplete({ $('#ajax-input').autocomplete({
source: data source: data.list
}); });
} }
}); });
......
...@@ -4,7 +4,7 @@ from __future__ import unicode_literals ...@@ -4,7 +4,7 @@ from __future__ import unicode_literals
from django.shortcuts import render from django.shortcuts import render
from catalog.forms import ASFSearchForm from catalog.forms import ASFSearchForm
from catalog.models import Polygon from catalog.models import Polygon
from django.http import HttpResponse from django.http import HttpResponse, JsonResponse
from django.urls import reverse from django.urls import reverse
from django.views.generic.base import View from django.views.generic.base import View
from django.template import loader from django.template import loader
...@@ -49,6 +49,52 @@ def productList(request): ...@@ -49,6 +49,52 @@ def productList(request):
return render(request,'productList.html',{}) #"catalog":json[0]}) return render(request,'productList.html',{}) #"catalog":json[0]})
# #-------------------------------------------------------------------------------
# class SearchSubmitView(View):
# template = 'map.html'
# # template = 'search_submit.html'
# state_parser = {'31': "Yucatán"}
#
# def post(self, request):
# template = loader.get_template(self.template)
# searchValue = request.POST.get('value', '')
#
# ## A simple query for Polygon objects whose name is 'searchValue'
# polygonList = Polygon.objects.filter(name=searchValue)
#
# # data = []
# list = []
# if len(polygonList) > 0:
# for polygon in polygonList:
# polygonInfo = json.loads(polygon.json_info)
#
# # data.append({
# # 'city' : polygon.name,
# # 'state' : self.state_parser[polygonInfo['properties']['CVE_ENT']],
# # 'geojson': polygon.json_info
# # })
# list.append({
# 'city': polygonInfo['properties']['NOMGEO'],
# 'state': self.state_parser[polygonInfo['properties']['CVE_ENT']],
# 'geojson': polygonInfo
# })
#
# # context = {
# # 'searchValue': searchValue,
# # 'data': json.dumps(data, ensure_ascii=True)
# # }
#
# data = {
# 'polList': list
# }
#
# # rendered_template = template.render(context, request)
# print("DATA:", data)
# # return HttpResponse(rendered_template, content_type='application/json')
# # return HttpResponse(json.dumps(data, ensure_ascii=True), content_type='application/json')
# return JsonResponse(data)
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
class SearchSubmitView(View): class SearchSubmitView(View):
template = 'map.html' template = 'map.html'
...@@ -78,15 +124,15 @@ class SearchSubmitView(View): ...@@ -78,15 +124,15 @@ class SearchSubmitView(View):
'geojson': polygonInfo 'geojson': polygonInfo
}) })
# context = { context = {
# 'searchValue': searchValue, 'searchValue': searchValue,
# 'data': json.dumps(data, ensure_ascii=True) 'data': data
# } }
# rendered_template = template.render(context, request) # rendered_template = template.render(context, request)
print("DATA:", data) print("DATA:", data)
# return HttpResponse(rendered_template, content_type='application/json') return render(request, self.template, context)
return HttpResponse(json.dumps(data, ensure_ascii=True), content_type='application/json') # return HttpResponse(json.dumps(data, ensure_ascii=True), content_type='application/json')
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
......
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