This commit is contained in:
Karen 2011-09-01 03:55:22 +05:30
commit ccad0ec56f
6 changed files with 77 additions and 4 deletions

View File

@ -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,13 @@ 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 = {
'type': 'FeatureCollection',
'features': features
}
return render_to_json_response(d)

View File

@ -1,5 +1,5 @@
$(function() {
$.getJSON("/auth_record_json", {
$.getJSON("/auth_record.json", {
'id': RECORD_ID
}, function(features) {
for (var i=0; i<features.features.length;i++) {

View File

@ -134,7 +134,7 @@ function onFeatureSelect(f) {
// $('.highlightOverlay').hide().remove();
// $('img').removeClass('mapSelect');
var $tr = $('#feature' + id);
$tr.css({"font-weight": "bold"});
$tr.css({"backgroundColor": "#C4DFFB"});
}
function onFeatureUnselect(f) {
@ -142,7 +142,7 @@ function onFeatureUnselect(f) {
// $('.highlightOverlay').hide().remove();
// $('img').removeClass('mapSelect');
var $tr = $('#feature' + id);
$tr.css({"font-weight": "normal"});
$tr.css({"backgroundColor": "#ffffff"});
}
/*

View 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;
}

View 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 %}

View File

@ -15,6 +15,7 @@ urlpatterns = patterns('',
('^search_related$', 'places.views.search_related'),
('^feature/(?P<id>\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')),