start view similar page

This commit is contained in:
Sanj 2011-08-29 18:22:10 +05:30
parent 4c9dcf7246
commit f4bb714dde
5 changed files with 26 additions and 5 deletions

View File

@ -1,6 +1,6 @@
# Create your views here.
from django.shortcuts import render_to_response
from ox.django.shortcuts import render_to_json_response
from ox.django.shortcuts import render_to_json_response, get_object_or_404
from django.template import RequestContext
from models import Feature
@ -27,8 +27,13 @@ def search_json(request):
def search_related(request):
d = RequestContext(request, {})
return render_to_response("search_related.html")
id = request.GET.get("id", "0")
feature = get_object_or_404(Feature, pk=id)
similar_features = feature.similar_features()
return render_to_response("search_related.html", {
'feature': feature,
'similar_features': similar_features
})
def search_related_json(request):

View File

@ -175,3 +175,7 @@ height:8.6%; /*HA HA HA HA HA HA HA DECIMALS should work, right*/
/*margin:0 auto;*/
background-color:grey;
clear:both;}
#mapList thead {
font-weight:bold;
}

View File

@ -40,6 +40,7 @@ function getRow(props) {
var $tr = $('<tr />');
var $one = $('<td />').appendTo($tr);
var $a = $('<a />').attr("target", "_blank").attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($one);
var $a2 = $('<a />').attr("target", "_blank").attr("href", "/search_related?id=" + props.id).text("view similar").appendTo($one);
$('<td />').text(props.feature_type).appendTo($tr);
$('<td />').text(props.admin2).appendTo($tr);
$('<td />').text(props.admin1).appendTo($tr);

View File

@ -0,0 +1,11 @@
<!doctype html>
<html>
<head>
<script type="text/javascript" src="/static/js/jquery.js"></script>
</head>
<body>
<h2>Similar features for {{ feature.preferred_name }}></h2>
</body>
</html>

View File

@ -11,8 +11,8 @@ urlpatterns = patterns('',
# (r'^gazetteer/', include('gazetteer.foo.urls')),
('^search$', 'places.views.search'),
('^search_json$', 'places.views.search_json'),
# ('^search_related$', 'places.views.search_related'),
# ('^search_related_json$', 'places.views.search_related.json'),
('^search_related$', 'places.views.search_related'),
('^search_related_json$', 'places.views.search_related.json'),
# Uncomment the admin/doc line below to enable admin documentation:
(r'^admin/doc/', include('django.contrib.admindocs.urls')),