Fix crash using create_user

Fix an invalid import usage to avoid a crash with the management
command create_user.

LEARNER-3932
This commit is contained in:
Michael Terry
2018-01-22 12:35:17 -05:00
committed by Michael Terry
parent e0bdd3773a
commit 948cae4148
2 changed files with 9 additions and 10 deletions

View File

@@ -128,13 +128,21 @@ def validate_username(username):
validator(username)
def contains_html(value):
"""
Validator method to check whether name contains html tags
"""
regex = re.compile('(<|>)', re.UNICODE)
return bool(regex.search(value))
def validate_name(name):
"""
Verifies a Full_Name is valid, raises a ValidationError otherwise.
Args:
name (unicode): The name to validate.
"""
if accounts_settings.api.contains_html(name):
if contains_html(name):
raise forms.ValidationError(_('Full Name cannot contain the following characters: < >'))