summaryrefslogtreecommitdiff
path: root/ishtar_common
diff options
context:
space:
mode:
authorÉtienne Loks <etienne.loks@iggdrasil.net>2021-03-01 18:33:14 +0100
committerÉtienne Loks <etienne.loks@iggdrasil.net>2021-03-01 18:34:48 +0100
commitde1c46ed53671bb5619b59cf5e063e44e2a016ae (patch)
treee0c5c21b33052ce7a20e027cd29d6989637cc12f /ishtar_common
parent8c020cdbc9eb693cd5197de7ff4f3cf12819fccd (diff)
downloadIshtar-de1c46ed53671bb5619b59cf5e063e44e2a016ae.tar.bz2
Ishtar-de1c46ed53671bb5619b59cf5e063e44e2a016ae.zip
Manage corrupted image - silently fail for now
Diffstat (limited to 'ishtar_common')
-rw-r--r--ishtar_common/forms_common.py7
-rw-r--r--ishtar_common/models.py5
2 files changed, 7 insertions, 5 deletions
diff --git a/ishtar_common/forms_common.py b/ishtar_common/forms_common.py
index 22a9e0279..8d57f0e3e 100644
--- a/ishtar_common/forms_common.py
+++ b/ishtar_common/forms_common.py
@@ -1552,9 +1552,10 @@ class DocumentForm(forms.ModelForm, CustomForm, ManageOldType):
not cleaned_data.get('image', None) and \
not cleaned_data.get('associated_file', None) and \
not cleaned_data.get('associated_url', None):
- raise forms.ValidationError(_("You should at least fill one of "
- "this field: title, url, image or "
- "file."))
+ raise forms.ValidationError(
+ _("You should at least fill one of this field: title, url, "
+ "image or file. If you have provided an image check that "
+ "it is not corrupted."))
for rel in models.Document.RELATED_MODELS:
if cleaned_data.get(rel, None):
return cleaned_data
diff --git a/ishtar_common/models.py b/ishtar_common/models.py
index 977b80ac6..4662bcc35 100644
--- a/ishtar_common/models.py
+++ b/ishtar_common/models.py
@@ -399,8 +399,9 @@ class ImageModel(models.Model, ImageContainerModel):
thumb_filename,
self.create_thumb(image, self.THUMB_MAX_SIZE),
save=False)
- except IOError:
- pass
+ except (IOError, ValueError):
+ self.thumbnail = None
+ self.image = None
finally:
if image:
image.close()