From f4bb714ddef5e4dcc8a3945d6463eaf039d516ed Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 29 Aug 2011 18:22:10 +0530 Subject: [PATCH] start view similar page --- gazetteer/places/views.py | 11 ++++++++--- gazetteer/static/css/main.css | 4 ++++ gazetteer/static/js/gazetteer.js | 1 + gazetteer/templates/search_related.html | 11 +++++++++++ gazetteer/urls.py | 4 ++-- 5 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index 894ba03..f991976 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -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): diff --git a/gazetteer/static/css/main.css b/gazetteer/static/css/main.css index a41fb4b..480a8f8 100644 --- a/gazetteer/static/css/main.css +++ b/gazetteer/static/css/main.css @@ -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; +} diff --git a/gazetteer/static/js/gazetteer.js b/gazetteer/static/js/gazetteer.js index 4273b45..2bae7cb 100644 --- a/gazetteer/static/js/gazetteer.js +++ b/gazetteer/static/js/gazetteer.js @@ -40,6 +40,7 @@ function getRow(props) { var $tr = $(''); var $one = $('').appendTo($tr); var $a = $('').attr("target", "_blank").attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($one); + var $a2 = $('').attr("target", "_blank").attr("href", "/search_related?id=" + props.id).text("view similar").appendTo($one); $('').text(props.feature_type).appendTo($tr); $('').text(props.admin2).appendTo($tr); $('').text(props.admin1).appendTo($tr); diff --git a/gazetteer/templates/search_related.html b/gazetteer/templates/search_related.html index e69de29..92be1a2 100644 --- a/gazetteer/templates/search_related.html +++ b/gazetteer/templates/search_related.html @@ -0,0 +1,11 @@ + + + + + + +

Similar features for {{ feature.preferred_name }}>

+ + + + diff --git a/gazetteer/urls.py b/gazetteer/urls.py index c769dbb..e7b8f26 100644 --- a/gazetteer/urls.py +++ b/gazetteer/urls.py @@ -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')),