summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES.md1
-rw-r--r--ishtar_common/forms_common.py7
-rw-r--r--ishtar_common/models.py5
3 files changed, 8 insertions, 5 deletions
diff --git a/CHANGES.md b/CHANGES.md
index f89952de4..d6181d237 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -7,6 +7,7 @@ v3.1.2 - 2021-03-01
### Bug fixes ###
- tables: pinned search do not overload click on shortcuts
- gallery: fix pagination
+- manage corrupted image - silently fail
v3.1.1 - 2021-02-28
--------------------
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()