summaryrefslogtreecommitdiff
path: root/chimere/views.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/views.py')
-rw-r--r--chimere/views.py33
1 files changed, 28 insertions, 5 deletions
diff --git a/chimere/views.py b/chimere/views.py
index 7c02216..79d4ac2 100644
--- a/chimere/views.py
+++ b/chimere/views.py
@@ -604,10 +604,17 @@ def getGeoObjects(request, area_name, category_ids, status):
idx = 0
current_cat = c_cat
colors = list(Color.objects.filter(color_theme = c_cat.color_theme))
+ color = '000'
if colors:
- jsons.append(route.getGeoJSON(color=colors[idx % len(colors)].code))
- else:
- jsons.append(route.getGeoJSON(color='000'))
+ color = colors[idx % len(colors)].code
+ if '#' not in color:
+ color = '#' + color
+ base_dct = {"type":"Feature",
+ "properties":{
+ "color":color
+ }
+ }
+ jsons.append(route._getItems(base_dct))
idx += 1
try:
q = checkDate(Q(status__in=status, categories__in=category_ids))
@@ -615,10 +622,26 @@ 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 category_id in category_ids:
+ cat = SubCategory.objects.get(pk=category_id)
+ base_dct = {"type":"Feature",
+ "properties":{
+ "icon_path":unicode(cat.icon.image),
+ "icon_hover_path":cat.hover_icon.image \
+ if cat.hover_icon else '',
+ "icon_width":cat.icon.image.width,
+ 'icon_height':cat.icon.image.height,
+ 'category_name':cat.name}
+ }
+ for obj in query.filter(categories__pk=category_id).all():
+ dct = base_dct.copy()
+ dct['properties'] = base_dct['properties'].copy()
+ jsons.append(obj._getItems(base_dct=dct))
if not jsons:
return HttpResponse('no results')
- data = '{"type": "FeatureCollection", "features":[%s]}' % ",".join(jsons)
+ data = {"type": "FeatureCollection", "features":jsons}
+ data = json.dumps(data)
+
return HttpResponse(data)
def get_all_categories(request, area_name=None):