diff options
Diffstat (limited to 'ishtar_common')
-rw-r--r-- | ishtar_common/forms_common.py | 15 | ||||
-rw-r--r-- | ishtar_common/models.py | 7 |
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: |