From 8491edfcf760cd6f7287790b40944b81ccfa2080 Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 1 Sep 2011 03:36:16 +0530 Subject: [PATCH 1/2] show features in time-frame admin --- gazetteer/places/views.py | 10 +++++- gazetteer/static/js/auth_record_admin.js | 2 +- gazetteer/static/js/gazetteer.js | 4 +-- gazetteer/static/js/time_frame_admin.js | 30 +++++++++++++++++ .../admin/places/timeframe/change_form.html | 33 +++++++++++++++++++ gazetteer/urls.py | 1 + 6 files changed, 76 insertions(+), 4 deletions(-) create mode 100644 gazetteer/static/js/time_frame_admin.js create mode 100644 gazetteer/templates/admin/places/timeframe/change_form.html diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index bc46b1d..847c817 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -106,7 +106,7 @@ def search_related_json(request, id): def auth_record_json(request): id = request.GET.get("id", "0") - auth_record = get_object_or_404(AuthorityRecord, pk=id) + auth_record = get_object_or_404_json(AuthorityRecord, pk=id) features = [f.get_geojson() for f in auth_record.feature_set.all()] d = { 'type': 'FeatureCollection', @@ -114,4 +114,12 @@ def auth_record_json(request): } return render_to_json_response(d) +def time_frame_json(request): + time_frame = get_object_or_404_json(AuthorityRecord, pk=id) + features = [f.get_geojson() for f in time_frame.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 index 22ae0ac..f7eab7b 100644 --- a/gazetteer/static/js/auth_record_admin.js +++ b/gazetteer/static/js/auth_record_admin.js @@ -1,5 +1,5 @@ $(function() { - $.getJSON("/auth_record_json", { + $.getJSON("/auth_record.json", { 'id': RECORD_ID }, function(features) { for (var i=0; i'); + var $one = $('').appendTo($tr); + var $a = $('').attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($one); + $('').text(props.uri).appendTo($tr); + $('').text(props.feature_type).appendTo($tr); + $('').text(props.admin2).appendTo($tr); + $('').text(props.admin1).appendTo($tr); + return $tr; +} + diff --git a/gazetteer/templates/admin/places/timeframe/change_form.html b/gazetteer/templates/admin/places/timeframe/change_form.html new file mode 100644 index 0000000..f4bc98b --- /dev/null +++ b/gazetteer/templates/admin/places/timeframe/change_form.html @@ -0,0 +1,33 @@ +{% extends 'admin/change_form.html' %} +{% block extrahead %} + {{ block.super }} + + + + + +{% endblock %} + +{% block after_related_objects %} +
+

List of Features:

+ + + + + + + + + + + + + + +
NameURITypeCountyState
+ +
+{% endblock %} diff --git a/gazetteer/urls.py b/gazetteer/urls.py index 8e875fd..c106ec3 100644 --- a/gazetteer/urls.py +++ b/gazetteer/urls.py @@ -15,6 +15,7 @@ urlpatterns = patterns('', ('^search_related$', 'places.views.search_related'), ('^feature/(?P\d+)/similar.json$', 'places.views.search_related_json'), ('^auth_record.json$', 'places.views.auth_record_json'), + ('^time_frame.json$', 'places.views.time_frame_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')), From 8e44644d66399c1afec5b4e8b394e7afe595c950 Mon Sep 17 00:00:00 2001 From: Sanj Date: Thu, 1 Sep 2011 03:46:50 +0530 Subject: [PATCH 2/2] ups --- gazetteer/places/views.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gazetteer/places/views.py b/gazetteer/places/views.py index 847c817..dcb48ee 100644 --- a/gazetteer/places/views.py +++ b/gazetteer/places/views.py @@ -115,6 +115,7 @@ def auth_record_json(request): return render_to_json_response(d) def time_frame_json(request): + id = request.GET.get("id", "0") time_frame = get_object_or_404_json(AuthorityRecord, pk=id) features = [f.get_geojson() for f in time_frame.feature_set.all()] d = {