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

region search view

parent b0d6074c
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
...@@ -120,9 +120,10 @@ ...@@ -120,9 +120,10 @@
<div class="form-group "> <div class="form-group ">
<!-- search form --> <!-- search form -->
<form action="#" method="get" class="sidebar-form"> <form action="{% url 'regionSearched' %}" method="post" class="sidebar-form">
{% csrf_token %}
<div class="input-group"> <div class="input-group">
<input type="text" name="q" class="form-control" placeholder="Search..."> <input type="text" name="value" class="form-control" placeholder="Search...">
<span class="input-group-btn"> <span class="input-group-btn">
<button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i> <button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
</button> </button>
......
...@@ -6,5 +6,6 @@ from . import views ...@@ -6,5 +6,6 @@ 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')
] ]
No preview for this file type
...@@ -3,6 +3,9 @@ from __future__ import unicode_literals ...@@ -3,6 +3,9 @@ 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 django.http import HttpResponseRedirect
from django.urls import reverse
from urllib import urlencode from urllib import urlencode
import requests import requests
...@@ -43,3 +46,17 @@ def productList(request): ...@@ -43,3 +46,17 @@ def productList(request):
# json = response.json() # json = response.json()
return render(request,'productList.html',{}) #"catalog":json[0]}) return render(request,'productList.html',{}) #"catalog":json[0]})
#-------------------------------------------------------------------------------
def regionSearched(request):
"""
View function for searching regions in DB
"""
city_name = request.POST['value']
cityList = Polygon.objects.filter(name=city_name)
if len(cityList) > 0:
print cityList
return HttpResponseRedirect(reverse('map'))
\ No newline at end of file
No preview for this file type
No preview for this file type
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