diff options
author | etienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864> | 2008-11-04 00:06:58 +0000 |
---|---|---|
committer | etienne <etienne@9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864> | 2008-11-04 00:06:58 +0000 |
commit | 6f97020d6b56f19d37a0941b299e68b2e8837d68 (patch) | |
tree | 1fcda40375cc872cbf26928e66482f30d5e8cf61 /main/models.py | |
parent | 030ed86130fabc78695355021b5a0586df3e77b9 (diff) | |
download | Chimère-6f97020d6b56f19d37a0941b299e68b2e8837d68.tar.bz2 Chimère-6f97020d6b56f19d37a0941b299e68b2e8837d68.zip |
Icon dimensions are automatically got from the file for correct display on the map
git-svn-id: http://www.peacefrogs.net/svn/chimere/trunk@2 9215b0d5-fb2c-4bbd-8d3e-bd2e9090e864
Diffstat (limited to 'main/models.py')
-rw-r--r-- | main/models.py | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/main/models.py b/main/models.py index 6d673d8..d4ba9be 100644 --- a/main/models.py +++ b/main/models.py @@ -27,7 +27,8 @@ class Icon(models.Model): '''Icon ''' name = models.CharField(_("Name"), max_length=150) - image = models.ImageField(_("Image"), upload_to='icons') + image = models.ImageField(_("Image"), upload_to='icons', + height_field='height', width_field='width') def __unicode__(self): return self.name class Meta: @@ -67,7 +68,8 @@ class Marker(models.Model): name = models.CharField(_("Name"), max_length=150) subcategory = models.ForeignKey(SubCategory, verbose_name=_("Subcategory")) point = PointField(_("Localisation")) - picture = models.ImageField(_("Image"), upload_to='upload', blank=True) + picture = models.ImageField(_("Image"), upload_to='upload', blank=True, + height_field='height', width_field='width') STATUS = (('S', _('Submited')), ('A', _('Available')), ('D', _('Disabled')),) @@ -120,10 +122,16 @@ class Marker(models.Model): def getGeoJSON(self): '''Return a GeoJSON string ''' - return """{"type":"Feature", "geometry":{"type":"Point", "crs": "EPSG:%(epsg)d", "coordinates":[%(longitude)s, %(latitude)s]}, "properties":{"pk": %(id)d, "name": "%(name)s", "icon_path":"%(icon_path)s"}}""" \ - % {'id':self.id, 'name':self.name, 'icon_path':self.subcategory.icon.image, -'latitude':self.getLatitude(), 'longitude':self.getLongitude(), -'epsg':settings.EPSG_PROJECTION} + print self.subcategory.icon.image + return """{"type":"Feature", "geometry":{"type":"Point", \ +"crs": "EPSG:%(epsg)d", "coordinates":[%(longitude)s, %(latitude)s]}, \ +"properties":{"pk": %(id)d, "name": "%(name)s", \ +"icon_path":"%(icon_path)s", "icon_width":%(icon_width)d, \ +"icon_height":%(icon_height)d}}""" % {'id':self.id, 'name':self.name, +'icon_path':self.subcategory.icon.image, 'latitude':self.getLatitude(), +'longitude':self.getLongitude(), 'epsg':settings.EPSG_PROJECTION, +'icon_width':self.subcategory.icon.image.width, +'icon_height':self.subcategory.icon.image.height,} class PropertyModel(models.Model): '''Model for a property |