fnp
/
redakcja.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
749077f
)
validate cover format on document create
author
Jan Szejko
<janek37@gmail.com>
Wed, 1 Feb 2017 16:06:45 +0000
(17:06 +0100)
committer
Jan Szejko
<janek37@gmail.com>
Wed, 1 Feb 2017 16:06:45 +0000
(17:06 +0100)
apps/catalogue/forms.py
patch
|
blob
|
history
diff --git
a/apps/catalogue/forms.py
b/apps/catalogue/forms.py
index
9301d9b
..
e6a6412
100644
(file)
--- a/
apps/catalogue/forms.py
+++ b/
apps/catalogue/forms.py
@@
-51,6
+51,12
@@
class DocumentCreateForm(forms.Form):
#
# return self.cleaned_data
#
# return self.cleaned_data
+ def clean_cover(self):
+ cover = self.cleaned_data['cover']
+ if cover.name.rsplit('.', 1)[-1].lower() not in ('jpg', 'jpeg', 'png', 'gif', 'tif', 'tiff'):
+ raise forms.ValidationError('The cover should be an image file (jpg/png/gif)')
+ return file
+
class DocumentsUploadForm(forms.Form):
"""
class DocumentsUploadForm(forms.Form):
"""