mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-11 09:28:27 -04:00
First slice of csv upload of phone numbers for sending messages.
At the moment the file contents are not persisted by checked in memory. The first and last three records are show if all are valid. If there are invalid rows, they are reported and the user is prompted to go back and sort out upload file. The storing of upload result (i.e. validation of file) in session will be removed in next story which is about persisting of file for later processing.
This commit is contained in:
@@ -38,3 +38,13 @@ class ValidateUserCodes(object):
|
||||
break
|
||||
if not valid_code:
|
||||
raise ValidationError(self.invalid_msg)
|
||||
|
||||
|
||||
class CsvFileValidator(object):
|
||||
|
||||
def __init__(self, message='Not a csv file'):
|
||||
self.message = message
|
||||
|
||||
def __call__(self, form, field):
|
||||
if not form.file.data.mimetype == 'text/csv':
|
||||
raise ValidationError(self.message)
|
||||
|
||||
Reference in New Issue
Block a user