mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-05-04 08:01:34 -04:00
Accept CSVs with 'email address' or 'phone number'
CSV files currently have ‘to’ as the recipient column. This is changing in https://github.com/alphagov/notifications-api/pull/109 The admin app also has to validate that the CSV files have the right columns, because the API expects any CSV that it’s given to have been checked (also we want things to actually work). This commit is the minimum code change needed. In the future it should reuse the same code as the API for processing CSV files. This will need more thinking.
This commit is contained in:
@@ -3,6 +3,8 @@ import re
|
||||
from functools import wraps
|
||||
from flask import (abort, session)
|
||||
|
||||
from utils.process_csv import get_recipient_from_row
|
||||
|
||||
|
||||
class BrowsableItem(object):
|
||||
"""
|
||||
@@ -87,11 +89,11 @@ def validate_email_address(email_address):
|
||||
raise InvalidEmailError('Not a valid email address')
|
||||
|
||||
|
||||
def validate_recipient(recipient, template_type):
|
||||
def validate_recipient(row, template_type):
|
||||
return {
|
||||
'email': validate_email_address,
|
||||
'sms': validate_phone_number
|
||||
}[template_type](recipient)
|
||||
}[template_type](get_recipient_from_row(row, template_type))
|
||||
|
||||
|
||||
def user_has_permissions(*permissions):
|
||||
|
||||
Reference in New Issue
Block a user