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
36431267
Commit
36431267
authored
May 22, 2018
by
Renán Sosa Guillen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prueba
parent
ac2f6292
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
4 deletions
+68
-4
map.html
catalog/templates/map.html
+1
-1
search_options.html
catalog/templates/search_options.html
+11
-0
search_submit.html
catalog/templates/search_submit.html
+16
-0
urls.py
catalog/urls.py
+3
-2
urls.pyc
catalog/urls.pyc
+0
-0
views.py
catalog/views.py
+37
-1
views.pyc
catalog/views.pyc
+0
-0
No files found.
catalog/templates/map.html
View file @
36431267
...
@@ -120,7 +120,7 @@
...
@@ -120,7 +120,7 @@
<div
class=
"form-group "
>
<div
class=
"form-group "
>
<!-- search form -->
<!-- search form -->
<form
action=
"{% url 'regionSearched
' %}"
method=
"post"
class=
"sidebar-form"
>
<form
role=
"form"
action=
"{% url 'search-submit
' %}"
method=
"post"
class=
"sidebar-form"
>
{% csrf_token %}
{% csrf_token %}
<div
class=
"input-group"
>
<div
class=
"input-group"
>
<input
type=
"text"
name=
"value"
class=
"form-control"
placeholder=
"Search..."
>
<input
type=
"text"
name=
"value"
class=
"form-control"
placeholder=
"Search..."
>
...
...
catalog/templates/search_options.html
0 → 100644
View file @
36431267
{% if searchValue %}
{% if data %}
<ul>
{% for pol in data %}
<li>
{{ pol.name }}
</li>
{% endfor %}
</ul>
{% endif %}
{% else %}
<h1>
ERROR
</h1>
{% endif %}
catalog/templates/search_submit.html
0 → 100644
View file @
36431267
<!DOCTYPE html>
<html
lang=
"en"
>
<head>
<meta
charset=
"UTF-8"
>
<title>
Title
</title>
</head>
<body>
{% if searchValue %}
{% if data %}
{% include 'search_options.html' %}
{% endif %}
{% else %}
<h1>
Nothing found.
</h1>
{% endif %}
</body>
</html>
\ No newline at end of file
catalog/urls.py
View file @
36431267
...
@@ -5,7 +5,8 @@ from . import views
...
@@ -5,7 +5,8 @@ from . import views
urlpatterns
=
[
urlpatterns
=
[
url
(
r'^$'
,
views
.
map
,
name
=
'map'
),
url
(
r'^$'
,
views
.
map
,
name
=
'map'
),
url
(
r'^productlist/'
,
views
.
productList
,
name
=
'productList'
),
url
(
r'^productlist/$'
,
views
.
productList
,
name
=
'productList'
),
url
(
r'^regionsearched/'
,
views
.
regionSearched
,
name
=
'regionSearched'
)
url
(
r'^regionsearched/$'
,
views
.
regionSearched
,
name
=
'regionSearched'
),
url
(
r'^searchsubmit/$'
,
views
.
SearchSubmitView
.
as_view
(),
name
=
'search-submit'
)
]
]
catalog/urls.pyc
View file @
36431267
No preview for this file type
catalog/views.py
View file @
36431267
...
@@ -6,8 +6,10 @@ from catalog.forms import ASFSearchForm
...
@@ -6,8 +6,10 @@ from catalog.forms import ASFSearchForm
from
catalog.models
import
Polygon
from
catalog.models
import
Polygon
from
django.http
import
HttpResponseRedirect
from
django.http
import
HttpResponseRedirect
from
django.urls
import
reverse
from
django.urls
import
reverse
from
django.views.generic.base
import
View
from
django.template
import
loader
from
urllib
import
urlencode
from
urllib
import
urlencode
import
requests
import
requests
,
json
# Create your views here.
# Create your views here.
...
@@ -47,6 +49,40 @@ def productList(request):
...
@@ -47,6 +49,40 @@ 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
=
[]
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
})
context
=
{
'searchValue'
:
searchValue
,
'data'
:
json
.
dumps
(
data
,
ensure_ascii
=
True
)
}
rendered_template
=
template
.
render
(
context
,
request
)
print
(
"Data:"
,
data
)
return
HttpResponse
(
rendered_template
,
content_type
=
'application/json'
)
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
def
regionSearched
(
request
):
def
regionSearched
(
request
):
"""
"""
...
...
catalog/views.pyc
View file @
36431267
No preview for this file type
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