summaryrefslogtreecommitdiff
path: root/ishtar_common/models.py
diff options
context:
space:
mode:
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
commit695d6c0f403f6970047c19c804e39391b9763271 (patch)
tree2cba33588e42ec214b3d30b4825e36e7c4e47b40 /ishtar_common/models.py
parent339df04ebd6047f1c41491db8c9e284afa43d2ad (diff)
parent49c9f8e285a9d75e08207ee697a81ac09c88a947 (diff)
downloadIshtar-695d6c0f403f6970047c19c804e39391b9763271.tar.bz2
Ishtar-695d6c0f403f6970047c19c804e39391b9763271.zip
Merge branch 'master-warehouse'
Diffstat (limited to 'ishtar_common/models.py')
-rw-r--r--ishtar_common/models.py46
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: