summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-27 15:47:32 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2018-02-27 15:47:32 +0100
commitd7e1978d8f5358652080f789303f59c3ddf07047 (patch)
treecb99bb453ae23db575810471c660dda06a98bd77 /ishtar_common
parente8880be9e7bd2183766178148083c85c3ee9d9a4 (diff)
downloadIshtar-d7e1978d8f5358652080f789303f59c3ddf07047.tar.bz2
Ishtar-d7e1978d8f5358652080f789303f59c3ddf07047.zip
Allow no resizing of images (by explicit parameter in settings)
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms_common.py15
-rw-r--r--ishtar_common/models.py7
2 files changed, 14 insertions, 8 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index f01c3e4b8..940ce99b8 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -870,6 +870,15 @@ class MergeOrganizationForm(MergeForm):
TO_KEY = 'to_organization'
+def get_image_help():
+ if not settings.IMAGE_MAX_SIZE:
+ return ""
+ return _(u"<p>Heavy images are resized to: %(width)dx%(height)d "
+ u"(ratio is preserved).</p>") \
+ % {'width': settings.IMAGE_MAX_SIZE[0],
+ 'height': settings.IMAGE_MAX_SIZE[1]}
+
+
######################
# Sources management #
######################
@@ -908,11 +917,7 @@ class SourceForm(CustomForm, ManageOldType):
duplicate = forms.BooleanField(label=_(u"Has a duplicate"),
required=False)
image = forms.ImageField(
- label=_(u"Image"), help_text=mark_safe(
- _(u"<p>Heavy images are resized to: %(width)dx%(height)d "
- u"(ratio is preserved).</p>") % {
- 'width': settings.IMAGE_MAX_SIZE[0],
- 'height': settings.IMAGE_MAX_SIZE[1]}),
+ label=_(u"Image"), help_text=mark_safe(get_image_help()),
max_length=255, required=False, widget=widgets.ImageFileInput())
TYPES = [
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index f482cf61d..6f8a66f3b 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -896,9 +896,10 @@ class ImageModel(models.Model):
image = image.convert('RGB')
# resize if necessary
- self.image.save(filename,
- self.create_thumb(image, self.IMAGE_MAX_SIZE),
- save=False)
+ if self.IMAGE_MAX_SIZE:
+ self.image.save(filename,
+ self.create_thumb(image, self.IMAGE_MAX_SIZE),
+ save=False)
if old_path != self.image.path:
try: