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: < >'))

View File

@@ -2,7 +2,6 @@
"""
Programmatic integration point for User API Accounts sub-application
"""
import re
import datetime
from pytz import UTC
@@ -539,14 +538,6 @@ def _get_user_and_profile(username):
return existing_user, existing_user_profile
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(validation_func, err, *args):
"""Generic validation function that returns default on
no errors, but the message associated with the err class