From 0fef41d028692ec97375b9a10376f2029e519042 Mon Sep 17 00:00:00 2001 From: Jan Szejko Date: Tue, 28 Feb 2017 15:56:56 +0100 Subject: [PATCH 1/1] accept empty cover in document save form --- apps/wiki/forms.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/apps/wiki/forms.py b/apps/wiki/forms.py index 4f5f7aa4..6db1903d 100644 --- a/apps/wiki/forms.py +++ b/apps/wiki/forms.py @@ -75,10 +75,12 @@ class DocumentTextSaveForm(forms.Form): raise ValidationError( "The first header should contain the title in plain text (no links, emphasis etc.) and cannot be empty") - ext = doc.meta.get_one(DCNS('relation.coverimage.url')).rsplit('.', 1)[-1].lower() - if ext not in ('jpg', 'jpeg', 'png', 'gif', 'tif', 'tiff'): - raise ValidationError('Invalid cover image format, should be an image file (jpg, png, gif). ' - 'Change it in Metadata.') + cover_url = doc.meta.get_one(DCNS('relation.coverimage.url')) + if cover_url: + ext = cover_url.rsplit('.', 1)[-1].lower() + if ext not in ('jpg', 'jpeg', 'png', 'gif', 'tif', 'tiff'): + raise ValidationError('Invalid cover image format, should be an image file (jpg, png, gif). ' + 'Change it in Metadata.') return text -- 2.20.1