summaryrefslogtreecommitdiff
path: root/chimere/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/views.py')
-rw-r--r--chimere/views.py18
1 files changed, 16 insertions, 2 deletions
diff --git a/chimere/views.py b/chimere/views.py
index 01179e4..4ca2498 100644
--- a/chimere/views.py
+++ b/chimere/views.py
@@ -28,6 +28,7 @@ import copy
import datetime
from itertools import groupby
import re
+import simplejson as json
from django.conf import settings
from django.contrib.auth import authenticate, login, logout
@@ -688,7 +689,14 @@ def getGeoObjects(request, map_name, category_ids, status):
data = {"type": "FeatureCollection", "features":jsons}
data = json.dumps(data)
- return HttpResponse(data)
+ return HttpResponse(data, content_type="application/json")
+
+def getMarker(request, map_name, pk):
+ q = Marker.objects.filter(pk=pk, status='A')
+ if not q.count():
+ return HttpResponse('{}')
+ data = q.all()[0].getGeoJSON()
+ return HttpResponse(data, content_type="application/json")
def get_all_categories(request, map_name=None):
'''
@@ -1023,9 +1031,15 @@ if hasattr(settings, 'CHIMERE_SEARCH_ENGINE') \
sqs = SearchQuerySet().autocomplete(
content_auto=request.GET.get('q', ''))[:5]
suggestions = [result.object.name for result in sqs if result.object]
+ spelling = []
+ if not suggestions:
+ spelling = SearchQuerySet().spelling_suggestion(
+ request.GET.get('q', '')) or []
+ # convert to list spelling...
# make sure it returns a JSON object, not a bare list.
# otherwise, it could be vulnerable to an XSS attack.
the_data = json.dumps({
- 'results': suggestions
+ 'results': suggestions,
+ 'spelling':spelling,
})
return HttpResponse(the_data, content_type='application/json')