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:
Adam Shimali
2016-01-11 15:00:51 +00:00
parent aa44a7b036
commit 584533eb11
7 changed files with 231 additions and 98 deletions

View File

@@ -1,7 +1,10 @@
from flask_wtf import Form
from wtforms import StringField, PasswordField, ValidationError
from wtforms import StringField, PasswordField, ValidationError, FileField
from wtforms.validators import DataRequired, Email, Length, Regexp
from app.main.validators import Blacklist, ValidateUserCodes
from app.main.validators import Blacklist, ValidateUserCodes, CsvFileValidator
from app.main.dao import verify_codes_dao
from app.main.encryption import check_hash
def email_address():
@@ -127,3 +130,9 @@ class ForgotPasswordForm(Form):
class NewPasswordForm(Form):
new_password = password()
class CsvUploadForm(Form):
file = FileField('File to upload',
validators=[DataRequired(message='Please pick a file'),
CsvFileValidator()])