From 279cb18b9157583a9def5ac9604cc66610bafffe Mon Sep 17 00:00:00 2001 From: Sanj Date: Wed, 31 Aug 2011 02:31:51 +0530 Subject: [PATCH] display time_frame and is_primary in similar features list --- gazetteer/places/views.py | 11 ++++++++++- gazetteer/static/js/feature_admin.js | 9 +++++++++ .../templates/admin/places/feature/change_form.html | 11 +++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index 3b1b6d1..69f5b2a 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -53,13 +53,22 @@ def search_related_json(request): feature = get_object_or_404(Feature, pk=id) similar_features = feature.similar_features() d = [] + for s in similar_features: + f = Feature.objects.get(pk=s.id) # This seems inefficient - better to get something like time_frame_id in models method? TODO + if f.time_frame is not None: + time_frame = f.time_frame.description + else: + time_frame = '' + d.append({ 'id': s.id, 'feature_type': FeatureType.objects.get(pk=s.feature_type_id).name, 'preferred_name': s.preferred_name, 'similarity': s.similarity, - 'distance': s.distance + 'distance': s.distance, + 'time_frame': time_frame, + 'is_primary': s.is_primary }) return render_to_json_response(d) diff --git a/gazetteer/static/js/feature_admin.js b/gazetteer/static/js/feature_admin.js index 729d24c..a80224f 100644 --- a/gazetteer/static/js/feature_admin.js +++ b/gazetteer/static/js/feature_admin.js @@ -16,5 +16,14 @@ function getRow(d) { $('').text(d.feature_type).appendTo($tr); $('').text(d.similarity).appendTo($tr); $('').text(d.distance).appendTo($tr); + $('').text(d.time_frame).appendTo($tr); + var $primary_td = $('').appendTo($tr); + var $checkbox = $('').attr("type", "checkbox").attr("disabled", "disabled").appendTo($primary_td); + if (d.is_primary) { + $checkbox.attr("checked", "checked"); + } else { + $.noop(); + } + return $tr; } diff --git a/gazetteer/templates/admin/places/feature/change_form.html b/gazetteer/templates/admin/places/feature/change_form.html index 0f6c547..5b5493c 100644 --- a/gazetteer/templates/admin/places/feature/change_form.html +++ b/gazetteer/templates/admin/places/feature/change_form.html @@ -32,6 +32,17 @@ Distance + + Time Frame + + + Is Primary? + +