mirror of
				https://gitlab.ub.uni-bielefeld.de/sfb1288inf/nopaque.git
				synced 2025-11-03 20:02:47 +00:00 
			
		
		
		
	Fix problems with new forms
This commit is contained in:
		
							
								
								
									
										0
									
								
								app/wtforms/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								app/wtforms/__init__.py
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										14
									
								
								app/wtforms/validators.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								app/wtforms/validators.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,14 @@
 | 
			
		||||
from wtforms.validators import ValidationError
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
def FileSize(max_size_mb):
 | 
			
		||||
    max_size_b = max_size_mb * 1024 * 1024
 | 
			
		||||
 | 
			
		||||
    def file_length_check(form, field):
 | 
			
		||||
        if len(field.data.read()) >= max_size_b:
 | 
			
		||||
            raise ValidationError(
 | 
			
		||||
                f'File size must be less or equal than {max_size_mb} MB'
 | 
			
		||||
            )
 | 
			
		||||
        field.data.seek(0)
 | 
			
		||||
 | 
			
		||||
    return file_length_check
 | 
			
		||||
		Reference in New Issue
	
	Block a user