summaryrefslogtreecommitdiff
path: root/chimere/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/models.py')
-rw-r--r--chimere/models.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/chimere/models.py b/chimere/models.py
index 3400118..c269439 100644
--- a/chimere/models.py
+++ b/chimere/models.py
@@ -171,7 +171,8 @@ class Color(models.Model):
"""
code = models.CharField(_(u"Code"), max_length=6)
order = models.IntegerField(_(u"Order"))
- color_theme = models.ForeignKey(ColorTheme, verbose_name=_(u"Color theme"))
+ color_theme = models.ForeignKey(ColorTheme, verbose_name=_(u"Color theme"),
+ related_name='colors')
def __unicode__(self):
return self.code
class Meta:
@@ -637,14 +638,24 @@ class Marker(GeographicItem):
if cat.hover_icon else '',
'icon_width':cat.icon.image.width,
'icon_height':cat.icon.image.height,
- 'category_name':json.dumps(cat.name)}
+ 'category_name':json.dumps(cat.name),}
+ items['weight'] = ''
+ if cat.weighted:
+ if not self.weight:
+ continue
+ items['weight'] = u', "weight":%d' % self.weight
+ if cat.color_theme and cat.color_theme.colors.count():
+ items['weight'] += u', "colors":["#%s"]' % '", "#'.join(
+ [color.code for color in cat.color_theme.colors.\
+ order_by('order').all()])
jsons.append(u'{"type":"Feature", "geometry":%(geometry)s, '\
u'"properties":{"pk": %(id)d, "name": %(name)s, '\
u'"icon_path":"%(icon_path)s", '\
u'"icon_hover_path":"%(icon_hover_path)s", '\
u'"icon_width":%(icon_width)d, '\
u'"icon_height":%(icon_height)d, '\
- u'"category_name":%(category_name)s}}' % items)
+ u'"category_name":%(category_name)s'\
+ u'%(weight)s}}' % items)
return ",".join(jsons)
@property