Implement client-side registration form validation.
Input forms that need validation will have AJAX requests performed to get validation decisions live. All but a few important and common form fields perform generic validation; these will need a back-end handler in the future in order to have them validated through AJAX requests. Information is conveyed on focus and blur for both errors and successes.
This commit is contained in:
@@ -22,7 +22,9 @@ from notification_prefs import NOTIFICATION_PREF_KEY
|
||||
from openedx.core.djangoapps.external_auth.models import ExternalAuthMap
|
||||
from openedx.core.djangoapps.lang_pref import LANGUAGE_KEY
|
||||
from openedx.core.djangoapps.site_configuration.tests.mixins import SiteMixin
|
||||
from openedx.core.djangoapps.user_api.accounts import USERNAME_INVALID_CHARS_ASCII, USERNAME_INVALID_CHARS_UNICODE
|
||||
from openedx.core.djangoapps.user_api.accounts import (
|
||||
USERNAME_BAD_LENGTH_MSG, USERNAME_INVALID_CHARS_ASCII, USERNAME_INVALID_CHARS_UNICODE
|
||||
)
|
||||
from openedx.core.djangoapps.user_api.preferences.api import get_user_preference
|
||||
from student.models import UserAttribute
|
||||
from student.views import REGISTRATION_AFFILIATE_ID, REGISTRATION_UTM_CREATED_AT, REGISTRATION_UTM_PARAMETERS
|
||||
@@ -476,16 +478,16 @@ class TestCreateAccountValidation(TestCase):
|
||||
|
||||
# Missing
|
||||
del params["username"]
|
||||
assert_username_error("Username must be minimum of two characters long")
|
||||
assert_username_error(USERNAME_BAD_LENGTH_MSG)
|
||||
|
||||
# Empty, too short
|
||||
for username in ["", "a"]:
|
||||
params["username"] = username
|
||||
assert_username_error("Username must be minimum of two characters long")
|
||||
assert_username_error(USERNAME_BAD_LENGTH_MSG)
|
||||
|
||||
# Too long
|
||||
params["username"] = "this_username_has_31_characters"
|
||||
assert_username_error("Username cannot be more than 30 characters long")
|
||||
assert_username_error(USERNAME_BAD_LENGTH_MSG)
|
||||
|
||||
# Invalid
|
||||
params["username"] = "invalid username"
|
||||
|
||||
@@ -5,6 +5,8 @@ import json
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.test import TestCase
|
||||
|
||||
from openedx.core.djangoapps.user_api.accounts import USERNAME_BAD_LENGTH_MSG
|
||||
|
||||
|
||||
class TestLongUsernameEmail(TestCase):
|
||||
|
||||
@@ -34,7 +36,7 @@ class TestLongUsernameEmail(TestCase):
|
||||
obj = json.loads(response.content)
|
||||
self.assertEqual(
|
||||
obj['value'],
|
||||
"Username cannot be more than 30 characters long",
|
||||
USERNAME_BAD_LENGTH_MSG,
|
||||
)
|
||||
|
||||
def test_long_email(self):
|
||||
|
||||
Reference in New Issue
Block a user