From: Jan Szejko Date: Tue, 28 Feb 2017 14:56:56 +0000 (+0100) Subject: accept empty cover in document save form X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/0fef41d028692ec97375b9a10376f2029e519042 accept empty cover in document save form --- 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