diff options
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 |