diff options
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r-- | ishtar_common/models.py | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/ishtar_common/models.py b/ishtar_common/models.py index f3974d04d..d8948d3e3 100644 --- a/ishtar_common/models.py +++ b/ishtar_common/models.py @@ -552,25 +552,27 @@ class ImageModel(models.Model): filename = os.path.splitext(os.path.split(self.image.name)[-1])[0] old_path = self.image.path filename = "%s.jpg" % filename - image = Image.open(self.image.file) - - # convert to RGB - if image.mode not in ('L', 'RGB'): - image = image.convert('RGB') - - # resize if necessary - self.image.save(filename, - self.create_thumb(image, self.IMAGE_MAX_SIZE), - save=False) - - if old_path != self.image.path: - os.remove(old_path) - - # save the thumbnail - self.thumbnail.save( - '_%s' % filename, - self.create_thumb(image, self.THUMB_MAX_SIZE), - save=False) + try: + image = Image.open(self.image.file) + # convert to RGB + if image.mode not in ('L', 'RGB'): + image = image.convert('RGB') + + # resize if necessary + self.image.save(filename, + self.create_thumb(image, self.IMAGE_MAX_SIZE), + save=False) + + if old_path != self.image.path: + os.remove(old_path) + + # save the thumbnail + self.thumbnail.save( + '_%s' % filename, + self.create_thumb(image, self.THUMB_MAX_SIZE), + save=False) + except IOError: + pass super(ImageModel, self).save(*args, **kwargs) @@ -581,6 +583,8 @@ class HistoryError(Exception): def __str__(self): return repr(self.value) +PRIVATE_FIELDS = ('id', 'history_modifier', 'order') + class BaseHistorizedItem(Imported): IS_BASKET = False @@ -816,6 +820,10 @@ class IshtarSiteProfile(models.Model, Cached): warehouse = models.BooleanField( _(u"Warehouses module"), default=False, help_text=_(u"Need finds module")) + homepage = models.TextField( + _(u"Home page"), null=True, blank=True, + help_text=_(u"Homepage of Ishtar - if not defined a default homepage " + u"will appear. Use the markdown syntax.")) active = models.BooleanField(_(u"Current active"), default=False) class Meta: |