diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-09-20 11:55:52 +0200 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-09-20 11:55:52 +0200 |
commit | ea953629c654b6264ef2e4932307bbccaf8c41d9 (patch) | |
tree | 660ce08aeac88b660c09c75016b1e2f5457a534a | |
parent | 356ccd0dc4eb0a6e768df59e94840452fc5109dc (diff) | |
download | Chimère-ea953629c654b6264ef2e4932307bbccaf8c41d9.tar.bz2 Chimère-ea953629c654b6264ef2e4932307bbccaf8c41d9.zip |
Don't crash if an icon is missing on the HDD
-rw-r--r-- | chimere/models.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/chimere/models.py b/chimere/models.py index ae1e014..e0b401b 100644 --- a/chimere/models.py +++ b/chimere/models.py @@ -356,12 +356,19 @@ class SubCategory(models.Model): return cats def getJSONDict(self): + # don't crash if some image have disapears + try: + width = self.icon.image.width + height = self.icon.image.height + except IOError: + width = 0 + height = 0 items = {'id': self.pk, 'name': self.name, 'description': self.description if self.description else '', 'icon': {'url': self.icon.image.url, - 'width': self.icon.image.width, - 'height': self.icon.image.height, + 'width': width, + 'height': height, 'offset_x': self.icon.offset_x, 'offset_y': self.icon.offset_y, 'popup_offset_x': self.icon.popup_offset_x, |