Validate column heading.

Still need to show that it is the heading that is wrong.
This commit is contained in:
Rebecca Law
2016-03-04 10:09:46 +00:00
parent 0fd2572b08
commit e3c692ede7
3 changed files with 28 additions and 4 deletions

View File

@@ -27,7 +27,8 @@ from app.main.dao import templates_dao
from app.main.dao import services_dao
from app import job_api_client
from app.utils import (
validate_recipient, InvalidPhoneError, InvalidEmailError, user_has_permissions)
validate_recipient, validate_header_row, InvalidPhoneError, InvalidEmailError, user_has_permissions,
InvalidHeaderError)
from utils.process_csv import first_column_heading
@@ -285,6 +286,7 @@ def _get_rows(contents, raw_template):
values=row,
drop_values={first_column_heading[raw_template['template_type']]}
).replaced
except (InvalidEmailError, InvalidPhoneError, NeededByTemplateError, NoPlaceholderForDataError):
except (InvalidEmailError, InvalidPhoneError, NeededByTemplateError,
NoPlaceholderForDataError, InvalidHeaderError):
valid = False
return {"valid": valid, "rows": rows}