show features in time-frame admin
This commit is contained in:
parent
6ac0aab378
commit
8491edfcf7
|
@ -106,7 +106,7 @@ def search_related_json(request, id):
|
||||||
|
|
||||||
def auth_record_json(request):
|
def auth_record_json(request):
|
||||||
id = request.GET.get("id", "0")
|
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()]
|
features = [f.get_geojson() for f in auth_record.feature_set.all()]
|
||||||
d = {
|
d = {
|
||||||
'type': 'FeatureCollection',
|
'type': 'FeatureCollection',
|
||||||
|
@ -114,4 +114,12 @@ def auth_record_json(request):
|
||||||
}
|
}
|
||||||
return render_to_json_response(d)
|
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)
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
$(function() {
|
$(function() {
|
||||||
$.getJSON("/auth_record_json", {
|
$.getJSON("/auth_record.json", {
|
||||||
'id': RECORD_ID
|
'id': RECORD_ID
|
||||||
}, function(features) {
|
}, function(features) {
|
||||||
for (var i=0; i<features.features.length;i++) {
|
for (var i=0; i<features.features.length;i++) {
|
||||||
|
|
|
@ -134,7 +134,7 @@ function onFeatureSelect(f) {
|
||||||
// $('.highlightOverlay').hide().remove();
|
// $('.highlightOverlay').hide().remove();
|
||||||
// $('img').removeClass('mapSelect');
|
// $('img').removeClass('mapSelect');
|
||||||
var $tr = $('#feature' + id);
|
var $tr = $('#feature' + id);
|
||||||
$tr.css({"font-weight": "bold"});
|
$tr.css({"backgroundColor": "#C4DFFB"});
|
||||||
}
|
}
|
||||||
|
|
||||||
function onFeatureUnselect(f) {
|
function onFeatureUnselect(f) {
|
||||||
|
@ -142,7 +142,7 @@ function onFeatureUnselect(f) {
|
||||||
// $('.highlightOverlay').hide().remove();
|
// $('.highlightOverlay').hide().remove();
|
||||||
// $('img').removeClass('mapSelect');
|
// $('img').removeClass('mapSelect');
|
||||||
var $tr = $('#feature' + id);
|
var $tr = $('#feature' + id);
|
||||||
$tr.css({"font-weight": "normal"});
|
$tr.css({"backgroundColor": "#ffffff"});
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
30
gazetteer/static/js/time_frame_admin.js
Normal file
30
gazetteer/static/js/time_frame_admin.js
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
$(function() {
|
||||||
|
$.getJSON("/time_frame.json", {
|
||||||
|
'id': TIMEFRAME_ID
|
||||||
|
}, function(features) {
|
||||||
|
for (var i=0; i<features.features.length;i++) {
|
||||||
|
var f = features.features[i];
|
||||||
|
var props = f.properties;
|
||||||
|
var listItem = getRow(props);
|
||||||
|
$('#mapList tbody').append(listItem);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
function copied over from gazetteer.js. TODO:resolve to DRY.
|
||||||
|
*/
|
||||||
|
function getRow(props) {
|
||||||
|
var $tr = $('<tr />');
|
||||||
|
var $one = $('<td />').appendTo($tr);
|
||||||
|
var $a = $('<a />').attr("href", "/admin/places/feature/" + props.id).text(props.preferred_name).appendTo($one);
|
||||||
|
$('<td />').text(props.uri).appendTo($tr);
|
||||||
|
$('<td />').text(props.feature_type).appendTo($tr);
|
||||||
|
$('<td />').text(props.admin2).appendTo($tr);
|
||||||
|
$('<td />').text(props.admin1).appendTo($tr);
|
||||||
|
return $tr;
|
||||||
|
}
|
||||||
|
|
33
gazetteer/templates/admin/places/timeframe/change_form.html
Normal file
33
gazetteer/templates/admin/places/timeframe/change_form.html
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
{% extends 'admin/change_form.html' %}
|
||||||
|
{% block extrahead %}
|
||||||
|
{{ block.super }}
|
||||||
|
<script type="text/javascript" src="/static/js/jquery.js"></script>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
TIMEFRAME_ID = {{ object_id }}
|
||||||
|
</script>
|
||||||
|
<script type="text/javascript" src="/static/js/time_frame_admin.js"></script>
|
||||||
|
<link rel="stylesheet" href="/static/css/feature_admin.css" />
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block after_related_objects %}
|
||||||
|
<div id="recordFeatures" class="module">
|
||||||
|
<h2>List of Features:</h2>
|
||||||
|
<table id="mapList" class="customTable">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>URI</th>
|
||||||
|
<th>Type</th>
|
||||||
|
<th>County</th>
|
||||||
|
<th>State</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
|
||||||
|
</tbody>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -15,6 +15,7 @@ urlpatterns = patterns('',
|
||||||
('^search_related$', 'places.views.search_related'),
|
('^search_related$', 'places.views.search_related'),
|
||||||
('^feature/(?P<id>\d+)/similar.json$', 'places.views.search_related_json'),
|
('^feature/(?P<id>\d+)/similar.json$', 'places.views.search_related_json'),
|
||||||
('^auth_record.json$', 'places.views.auth_record_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:
|
# Uncomment the admin/doc line below to enable admin documentation:
|
||||||
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
|
||||||
(r'^ajax_select/', include('ajax_select.urls')),
|
(r'^ajax_select/', include('ajax_select.urls')),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user