|
|
|
@ -56,7 +56,7 @@ from PIL import Image
|
|
|
|
|
def validate_file(form, field):
|
|
|
|
|
file = request.files.get(field.name)
|
|
|
|
|
if not file or file.filename == '':
|
|
|
|
|
raise ValidationError('Please select a file')
|
|
|
|
|
raise ValidationError('Please select a file.')
|
|
|
|
|
|
|
|
|
|
class UploadForm(CSRFForm):
|
|
|
|
|
post_img = FileField('Image', validators=[validate_file], render_kw={'required':''})
|
|
|
|
@ -79,7 +79,7 @@ class UploadForm(CSRFForm):
|
|
|
|
|
# flash(real_mimetype)
|
|
|
|
|
# if client_mimetype != real_mimetype or client_mimetype not in ['image/png','image/jpeg']:
|
|
|
|
|
if real_mimetype not in ['image/png','image/jpeg']:
|
|
|
|
|
raise ValidationError('Please select an image file of PNG or JPEG format')
|
|
|
|
|
raise ValidationError('Please select an image file of PNG or JPEG format.')
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
Image.open(file).verify()
|
|
|
|
@ -94,7 +94,7 @@ class UploadForm(CSRFForm):
|
|
|
|
|
|
|
|
|
|
width, height = fileinfo['resolution']
|
|
|
|
|
if width*height<1280*720 or width<720 or height<720:
|
|
|
|
|
raise ValidationError('Image has too low resolution, according to rules.')
|
|
|
|
|
raise ValidationError('Image has too low resolution.')
|
|
|
|
|
|
|
|
|
|
# Change user section
|
|
|
|
|
class ChangeUserInfoForm(CSRFForm):
|
|
|
|
|