From 0ac0ca923687e1355ac3bc4217ba3c23eb42944a Mon Sep 17 00:00:00 2001 From: Sanj Date: Tue, 30 Aug 2011 22:56:53 +0530 Subject: [PATCH] add list of features in authority record admin; cleaner urls for json end-points --- gazetteer/places/views.py | 14 ++++++++- gazetteer/static/js/auth_record_admin.js | 30 +++++++++++++++++++ gazetteer/static/js/feature_admin.js | 2 +- gazetteer/static/js/gazetteer.js | 2 +- .../places/authorityrecord/change_form.html | 29 ++++++++++++++++++ gazetteer/urls.py | 5 ++-- 6 files changed, 77 insertions(+), 5 deletions(-) create mode 100644 gazetteer/static/js/auth_record_admin.js diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index 8b599e4..22331bf 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -61,4 +61,16 @@ def search_related_json(request): 'similarity': s.similarity, 'distance': s.distance }) - return render_to_json_response(d) + return render_to_json_response(d) + +def auth_record_json(request): + id = request.GET.get("id", "0") + auth_record = get_object_or_404(AuthorityRecord, pk=id) + features = [f.get_geojson() for f in auth_record.feature_set.all()] + d = { + 'type': 'FeatureCollection', + 'features': features + } + return render_to_json_response(d) + + diff --git a/gazetteer/static/js/auth_record_admin.js b/gazetteer/static/js/auth_record_admin.js new file mode 100644 index 0000000..f4f09fd --- /dev/null +++ b/gazetteer/static/js/auth_record_admin.js @@ -0,0 +1,30 @@ +$(function() { + $.getJSON("/auth_record_json", { + 'id': RECORD_ID + }, function(features) { + for (var i=0; i'); + var $one = $('').appendTo($tr); + var $a = $('').attr("target", "_blank").attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name + " ").appendTo($one); + var $a2 = $('').addClass("viewSimilar").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); + return $tr; +} + diff --git a/gazetteer/static/js/feature_admin.js b/gazetteer/static/js/feature_admin.js index 5afbd8e..729d24c 100644 --- a/gazetteer/static/js/feature_admin.js +++ b/gazetteer/static/js/feature_admin.js @@ -1,5 +1,5 @@ $(function() { - $.getJSON("/search_related_json", { + $.getJSON("/feature/search_related.json", { 'id': FEATURE_ID }, function(data) { for (var i=0; i + + + +{% endblock %} + +% block after_related_objects %} +
+ + + + + + + + + + + + + +
NameTypeCountyState
+ +
+{% endblock %} diff --git a/gazetteer/urls.py b/gazetteer/urls.py index a1a169b..7031e4f 100644 --- a/gazetteer/urls.py +++ b/gazetteer/urls.py @@ -10,9 +10,10 @@ urlpatterns = patterns('', # Example: # (r'^gazetteer/', include('gazetteer.foo.urls')), ('^search$', 'places.views.search'), - ('^search_json$', 'places.views.search_json'), + ('^feature/search.json$', 'places.views.search_json'), ('^search_related$', 'places.views.search_related'), - ('^search_related_json$', 'places.views.search_related_json'), + ('^feature/search_related.json$', 'places.views.search_related_json'), + ('^auth_record.json$', 'places.views.auth_record_json'), # Uncomment the admin/doc line below to enable admin documentation: (r'^admin/doc/', include('django.contrib.admindocs.urls')), (r'^ajax_select/', include('ajax_select.urls')),