added margins

This commit is contained in:
Karen 2011-08-31 18:57:04 +05:30
commit ee34919e6a
4 changed files with 20 additions and 7 deletions

View File

@ -1,6 +1,6 @@
# Create your views here. # Create your views here.
from django.shortcuts import render_to_response, get_object_or_404 from django.shortcuts import render_to_response, get_object_or_404
from ox.django.shortcuts import render_to_json_response from ox.django.shortcuts import render_to_json_response, get_object_or_404_json
from django.template import RequestContext from django.template import RequestContext
from models import Feature, FeatureType, AuthorityRecord from models import Feature, FeatureType, AuthorityRecord
from django.core.paginator import Paginator, InvalidPage, EmptyPage from django.core.paginator import Paginator, InvalidPage, EmptyPage
@ -79,9 +79,10 @@ def search_related(request):
}) })
def search_related_json(request): def search_related_json(request, id):
id = request.GET.get("id", "0") # id = request.GET.get("id", "0")
feature = get_object_or_404(Feature, pk=id) id = str(id)
feature = get_object_or_404_json(Feature, pk=id)
similar_features = feature.similar_features() similar_features = feature.similar_features()
d = [] d = []

View File

@ -17,12 +17,24 @@ $(function() {
var bbox = map.getExtent().toBBOX(); var bbox = map.getExtent().toBBOX();
var search_term = $('#search').val(); var search_term = $('#search').val();
$('#searchField').addClass("loading"); $('#searchField').addClass("loading");
$('#searchField').attr("disabled", "disabled");
$.getJSON("/feature/search.json", { $.getJSON("/feature/search.json", {
'bbox': bbox, 'bbox': bbox,
'q': search_term, 'q': search_term,
'srid': 3785, 'srid': 3785,
'threshold': 0.5 'threshold': 0.5,
'count': 20
}, function(features) { }, function(features) {
if (features.hasOwnProperty("error") && features.error != '') {
alert(features.error);
return;
}
$('#noOfResults').text(features.results);
$('#currPage').text(features.current_page);
$('#totalPages').text(features.pages);
$('#searchField').removeAttr("disabled");
$('#searchField').removeClass("loading"); $('#searchField').removeClass("loading");
$('#mapList tbody').empty(); $('#mapList tbody').empty();
// var headerRow = getHeaderRow(); // var headerRow = getHeaderRow();

View File

@ -2,7 +2,7 @@
{% block extrahead %} {% block extrahead %}
{{ block.super }} {{ block.super }}
<script type="text/javascript" src="/static/js/jquery.js"></script> <script type="text/javascript" src="/static/js/jquery.js"></script>
<script type="text/javascript" src="/static/js/jquery.autocomplete.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
RECORD_ID = {{ object_id }} RECORD_ID = {{ object_id }}
</script> </script>

View File

@ -13,7 +13,7 @@ urlpatterns = patterns('',
('^search$', 'places.views.search'), ('^search$', 'places.views.search'),
('^feature/search.json$', 'places.views.search_json'), ('^feature/search.json$', 'places.views.search_json'),
('^search_related$', 'places.views.search_related'), ('^search_related$', 'places.views.search_related'),
('^feature/search_related.json$', 'places.views.search_related_json'), ('^feature/(?P<id>[0-9]*)/similar.json$', 'places.views.search_related_json'),
('^auth_record.json$', 'places.views.auth_record_json'), ('^auth_record.json$', 'places.views.auth_record_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')),