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 @@
<div class="form-group ">
<!-- search form -->
<form action="#" method="get" class="sidebar-form">
<form action="{% url 'regionSearched' %}" method="post" class="sidebar-form">
{% csrf_token %}
<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">
<button type="submit" name="search" id="search-btn" class="btn btn-flat"><i class="fa fa-search"></i>
</button>
......
......@@ -6,5 +6,6 @@ from . import views
urlpatterns = [
url(r'^$', views.map, name='map'),
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
from django.shortcuts import render
from catalog.forms import ASFSearchForm
from catalog.models import Polygon
from django.http import HttpResponseRedirect
from django.urls import reverse
from urllib import urlencode
import requests
......@@ -10,36 +13,50 @@ import requests
# Create your views here.
#-------------------------------------------------------------------------------
def login(request):
"""
View function for home page of site.
"""
"""
View function for home page of site.
"""
# Render the HTML template index.html with the data in the context variable
return render(request,'login.html',{})
# Render the HTML template index.html with the data in the context variable
return render(request,'login.html',{})
#-------------------------------------------------------------------------------
def map(request):
"""
View function for home page of site.
"""
form = ASFSearchForm(request.POST)
"""
View function for home page of site.
"""
form = ASFSearchForm(request.POST)
# Render the HTML template index.html with the data in the context variable
return render(request,'map.html',{"searchForm":form})
# Render the HTML template index.html with the data in the context variable
return render(request,'map.html',{"searchForm":form})
#-------------------------------------------------------------------------------
def productList(request):
"""
View function for home page of site.
"""
r2 = dict(request.POST)
r2.pop('csrfmiddlewaretoken', None)
"""
View function for home page of site.
"""
r2 = dict(request.POST)
r2.pop('csrfmiddlewaretoken', None)
url = 'https://api.daac.asf.alaska.edu/services/search/param?'+urlencode(r2, 'utf-8')+"&output=JSON"
print url
url = 'https://api.daac.asf.alaska.edu/services/search/param?'+urlencode(r2, 'utf-8')+"&output=JSON"
print url
# response = requests.get(url)
# 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