From 67a4a7ce9469f39c894159db3ea5257242b7f2b4 Mon Sep 17 00:00:00 2001 From: Sanj Date: Mon, 29 Aug 2011 18:33:29 +0530 Subject: [PATCH] basic similar features page --- gazetteer/places/views.py | 1 + gazetteer/static/js/gazetteer.js | 2 +- gazetteer/templates/search_related.html | 38 +++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index d1f2d44..d93795f 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -30,6 +30,7 @@ def search_related(request): 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 diff --git a/gazetteer/static/js/gazetteer.js b/gazetteer/static/js/gazetteer.js index 2bae7cb..c013055 100644 --- a/gazetteer/static/js/gazetteer.js +++ b/gazetteer/static/js/gazetteer.js @@ -39,7 +39,7 @@ $(function() { 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 $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); diff --git a/gazetteer/templates/search_related.html b/gazetteer/templates/search_related.html index 92be1a2..7791a16 100644 --- a/gazetteer/templates/search_related.html +++ b/gazetteer/templates/search_related.html @@ -6,6 +6,44 @@

Similar features for {{ feature.preferred_name }}>

+ + + + + + + + + + + {% for s in similar_features %} + + + + + + + {% endfor %} + + + +
+ Name + + Feature Type + + Similarity + + Distance +
+ {{ s.preferred_name }} + + {{ s.feature_type_id }} + + {{ s.similarity }} + + {{ s.distance }} +