diff options
| author | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-04-05 14:28:35 +0200 |
|---|---|---|
| committer | Étienne Loks <etienne.loks@peacefrogs.net> | 2013-04-05 14:28:35 +0200 |
| commit | 426eb4711ff92cc0e6df9cd1004ff322f112c814 (patch) | |
| tree | a1884d4c36beb027207a964974ca3f7c3d0a9eb5 /chimere/models.py | |
| parent | 1ab25dfc2603d6145a7ca6100558e470761ce766 (diff) | |
| download | Chimère-426eb4711ff92cc0e6df9cd1004ff322f112c814.tar.bz2 Chimère-426eb4711ff92cc0e6df9cd1004ff322f112c814.zip | |
Weighted markers: first display with Leaflet
Diffstat (limited to 'chimere/models.py')
| -rw-r--r-- | chimere/models.py | 17 |
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 |
