diff options
| author | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-06-08 18:13:35 +0200 | 
|---|---|---|
| committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2016-06-08 18:13:35 +0200 | 
| commit | f54d386b714f3a1abef103006e36972776d2028e (patch) | |
| tree | 2cba33588e42ec214b3d30b4825e36e7c4e47b40 /ishtar_common/models.py | |
| parent | 316dc98ccdee59d6d4709f2a9e253cc258b2037e (diff) | |
| parent | aef35a14f4bd3f3f87c1e19188d57cc66e6694b6 (diff) | |
| download | Ishtar-f54d386b714f3a1abef103006e36972776d2028e.tar.bz2 Ishtar-f54d386b714f3a1abef103006e36972776d2028e.zip | |
Merge branch 'master-warehouse'
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: | 
