summaryrefslogtreecommitdiff
path: root/chimere/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/views.py')
-rw-r--r--chimere/views.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/chimere/views.py b/chimere/views.py
index 8daa432..5beb5fd 100644
--- a/chimere/views.py
+++ b/chimere/views.py
@@ -27,6 +27,7 @@ Views of the project
import datetime
from itertools import groupby
import re
+import simplejson as json
from django.conf import settings
from django.contrib.gis.geos import GEOSGeometry
@@ -617,9 +618,10 @@ def getGeoObjects(request, area_name, category_ids, status):
current_cat = c_cat
colors = list(Color.objects.filter(color_theme = c_cat.color_theme))
if colors:
- jsons.append(route.getGeoJSON(color=colors[idx % len(colors)].code))
+ jsons.append(json.loads(
+ route.getGeoJSON(color=colors[idx % len(colors)].code)))
else:
- jsons.append(route.getGeoJSON(color='000'))
+ jsons.append(json.loads(route.getGeoJSON(color='000')))
idx += 1
try:
q = checkDate(Q(status__in=status, categories__in=category_ids))
@@ -627,11 +629,19 @@ def getGeoObjects(request, area_name, category_ids, status):
except:
return HttpResponse('no results')
category_ids = [int(cat_id) for cat_id in category_ids]
- jsons += [geo_object.getGeoJSON(category_ids) for geo_object in list(query)]
+ for geo_object in list(query):
+ jsons += json.loads(geo_object.getGeoJSON(category_ids))
if not jsons:
return HttpResponse('no results')
- data = '{"type": "FeatureCollection", "features":[%s]}' % ",".join(jsons)
- return HttpResponse(data)
+ data = json.dumps({"type": "FeatureCollection", "features":jsons})
+ return HttpResponse(data, content_type="application/json")
+
+def getMarker(request, area_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, area_name=None):
'''