basic similar features page

This commit is contained in:
Sanj 2011-08-29 18:33:29 +05:30
parent 5493c5f251
commit 67a4a7ce94
3 changed files with 40 additions and 1 deletions

View File

@ -30,6 +30,7 @@ def search_related(request):
id = request.GET.get("id", "0") id = request.GET.get("id", "0")
feature = get_object_or_404(Feature, pk=id) feature = get_object_or_404(Feature, pk=id)
similar_features = feature.similar_features() similar_features = feature.similar_features()
return render_to_response("search_related.html", { return render_to_response("search_related.html", {
'feature': feature, 'feature': feature,
'similar_features': similar_features 'similar_features': similar_features

View File

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

View File

@ -6,6 +6,44 @@
<body> <body>
<h2>Similar features for {{ feature.preferred_name }}></h2> <h2>Similar features for {{ feature.preferred_name }}></h2>
<table id="similarTable">
<thead>
<tr>
<td>
Name
</td>
<td>
Feature Type
</td>
<td>
Similarity
</td>
<td>
Distance
</td>
</tr>
</thead>
<tbody>
{% for s in similar_features %}
<tr>
<td>
{{ s.preferred_name }}
</td>
<td>
{{ s.feature_type_id }}
</td>
<td>
{{ s.similarity }}
</td>
<td>
{{ s.distance }}
</td>
<tr>
{% endfor %}
</tbody>
</table>
</body> </body>
</html> </html>