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
24a3b528
Commit
24a3b528
authored
May 23, 2018
by
Emmanuel René Huchim Puc
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dev' of gitlab.geoint.mx:mario.chirinos/GeoInt_SIDT into dev
parents
f4f466c6
9e8ef6f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
56 deletions
+57
-56
dataRetrieval.js
catalog/static/js/dataRetrieval.js
+4
-3
views.py
catalog/views.py
+53
-53
No files found.
catalog/static/js/dataRetrieval.js
View file @
24a3b528
...
...
@@ -45,7 +45,7 @@ $(document).ready(function () {
var
input
=
document
.
getElementById
(
'ajax-input'
);
var
dataList
=
document
.
getElementById
(
'polygon-list'
);
$
(
'#ajax-input'
).
on
(
'
input
'
,
function
(
e
)
{
$
(
'#ajax-input'
).
on
(
'
keyup
'
,
function
(
e
)
{
var
value
=
$
(
this
).
val
();
if
(
value
===
''
)
return
;
...
...
@@ -61,7 +61,7 @@ $(document).ready(function () {
},
dataType
:
'json'
,
success
:
function
(
data
)
{
// console.log("DATA: ", data);
// console.log("DATA: ", data
.polygonList
);
// data.forEach(function(polygon) {
// console.log(polygon);
// // Create a new <option> element
...
...
@@ -72,7 +72,8 @@ $(document).ready(function () {
// dataList.appendChild(option);
// });
$
(
'#ajax-input'
).
autocomplete
({
source
:
data
.
list
source
:
data
.
polygonList
,
minLength
:
3
});
}
});
...
...
catalog/views.py
View file @
24a3b528
...
...
@@ -4,7 +4,7 @@ from __future__ import unicode_literals
from
django.shortcuts
import
render
from
catalog.forms
import
ASFSearchForm
from
catalog.models
import
Polygon
from
django.http
import
HttpResponse
,
JsonResponse
from
django.http
import
HttpResponse
,
JsonResponse
,
HttpResponseRedirect
from
django.urls
import
reverse
from
django.views.generic.base
import
View
from
django.template
import
loader
...
...
@@ -49,52 +49,6 @@ def productList(request):
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
):
template
=
'map.html'
...
...
@@ -108,7 +62,8 @@ class SearchSubmitView(View):
## A simple query for Polygon objects whose name is 'searchValue'
polygonList
=
Polygon
.
objects
.
filter
(
name
=
searchValue
)
data
=
[]
# data = []
list
=
[]
if
len
(
polygonList
)
>
0
:
for
polygon
in
polygonList
:
polygonInfo
=
json
.
loads
(
polygon
.
json_info
)
...
...
@@ -118,21 +73,66 @@ class SearchSubmitView(View):
# 'state' : self.state_parser[polygonInfo['properties']['CVE_ENT']],
# 'geojson': polygon.json_info
# })
data
.
append
({
list
.
append
({
'city'
:
polygonInfo
[
'properties'
][
'NOMGEO'
],
'state'
:
self
.
state_parser
[
polygonInfo
[
'properties'
][
'CVE_ENT'
]],
'geojson'
:
polygonInfo
})
context
=
{
'searchValue'
:
searchValue
,
'data'
:
data
# context = {
# 'searchValue': searchValue,
# 'data': json.dumps(data, ensure_ascii=True)
# }
data
=
{
'polygonList'
:
list
}
# rendered_template = template.render(context, request)
print
(
"DATA:"
,
data
)
return
render
(
request
,
self
.
template
,
context
)
# 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):
# 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 = []
# 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
# # })
# data.append({
# 'city': polygonInfo['properties']['NOMGEO'],
# 'state': self.state_parser[polygonInfo['properties']['CVE_ENT']],
# 'geojson': polygonInfo
# })
#
# context = {
# 'searchValue': searchValue,
# 'data': data
# }
#
# # rendered_template = template.render(context, request)
# print("DATA:", data)
# # return render(request, self.template, context)
# return HttpResponseRedirect(reverse(map), json.dumps(data, ensure_ascii=True), content_type='application/json')
#-------------------------------------------------------------------------------
...
...
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