Edited contrib.auth check messages for grammar and consistency.

This commit is contained in:
Russell Keith-Magee 2014-03-03 13:39:58 +08:00
parent 3c5fc708f1
commit 84207b6134
2 changed files with 14 additions and 17 deletions

View File

@ -15,7 +15,7 @@ def check_user_model(**kwargs):
if not isinstance(cls.REQUIRED_FIELDS, (list, tuple)): if not isinstance(cls.REQUIRED_FIELDS, (list, tuple)):
errors.append( errors.append(
checks.Error( checks.Error(
'The REQUIRED_FIELDS must be a list or tuple.', "'REQUIRED_FIELDS' must be a list or tuple.",
hint=None, hint=None,
obj=cls, obj=cls,
id='auth.E001', id='auth.E001',
@ -26,9 +26,8 @@ def check_user_model(**kwargs):
if cls.USERNAME_FIELD in cls.REQUIRED_FIELDS: if cls.USERNAME_FIELD in cls.REQUIRED_FIELDS:
errors.append( errors.append(
checks.Error( checks.Error(
('The field named as the USERNAME_FIELD ' ("The field named as the 'USERNAME_FIELD' "
'must not be included in REQUIRED_FIELDS ' "for a custom user model must not be included in 'REQUIRED_FIELDS'."),
'on a custom user model.'),
hint=None, hint=None,
obj=cls, obj=cls,
id='auth.E002', id='auth.E002',
@ -41,8 +40,7 @@ def check_user_model(**kwargs):
('django.contrib.auth.backends.ModelBackend',)): ('django.contrib.auth.backends.ModelBackend',)):
errors.append( errors.append(
checks.Error( checks.Error(
('The %s.%s field must be unique because it is ' "'%s.%s' must be unique because it is named as the 'USERNAME_FIELD'." % (
'pointed to by USERNAME_FIELD.') % (
cls._meta.object_name, cls.USERNAME_FIELD cls._meta.object_name, cls.USERNAME_FIELD
), ),
hint=None, hint=None,
@ -53,11 +51,10 @@ def check_user_model(**kwargs):
else: else:
errors.append( errors.append(
checks.Warning( checks.Warning(
('The %s.%s field is pointed to by USERNAME_FIELD, ' "'%s.%s' is named as the 'USERNAME_FIELD', but it is not unique." % (
'but it is not unique.') % (
cls._meta.object_name, cls.USERNAME_FIELD cls._meta.object_name, cls.USERNAME_FIELD
), ),
hint=('Ensure that your authentication backend can handle ' hint=('Ensure that your authentication backend(s) can handle '
'non-unique usernames.'), 'non-unique usernames.'),
obj=cls, obj=cls,
id='auth.W004', id='auth.W004',

View File

@ -358,7 +358,7 @@ class CustomUserModelValidationTestCase(TestCase):
errors = checks.run_checks() errors = checks.run_checks()
expected = [ expected = [
checks.Error( checks.Error(
'The REQUIRED_FIELDS must be a list or tuple.', "'REQUIRED_FIELDS' must be a list or tuple.",
hint=None, hint=None,
obj=CustomUserNonListRequiredFields, obj=CustomUserNonListRequiredFields,
id='auth.E001', id='auth.E001',
@ -375,8 +375,8 @@ class CustomUserModelValidationTestCase(TestCase):
errors = checks.run_checks() errors = checks.run_checks()
expected = [ expected = [
checks.Error( checks.Error(
('The field named as the USERNAME_FIELD must not be included ' ("The field named as the 'USERNAME_FIELD' for a custom user model "
'in REQUIRED_FIELDS on a custom user model.'), "must not be included in 'REQUIRED_FIELDS'."),
hint=None, hint=None,
obj=CustomUserBadRequiredFields, obj=CustomUserBadRequiredFields,
id='auth.E002', id='auth.E002',
@ -393,8 +393,8 @@ class CustomUserModelValidationTestCase(TestCase):
errors = checks.run_checks() errors = checks.run_checks()
expected = [ expected = [
checks.Error( checks.Error(
('The CustomUserNonUniqueUsername.username field must be ' ("'CustomUserNonUniqueUsername.username' must be "
'unique because it is pointed to by USERNAME_FIELD.'), "unique because it is named as the 'USERNAME_FIELD'."),
hint=None, hint=None,
obj=CustomUserNonUniqueUsername, obj=CustomUserNonUniqueUsername,
id='auth.E003', id='auth.E003',
@ -416,9 +416,9 @@ class CustomUserModelValidationTestCase(TestCase):
errors = checks.run_checks() errors = checks.run_checks()
expected = [ expected = [
checks.Warning( checks.Warning(
('The CustomUserNonUniqueUsername.username field is pointed to ' ("'CustomUserNonUniqueUsername.username' is named as "
'by USERNAME_FIELD, but it is not unique.'), "the 'USERNAME_FIELD', but it is not unique."),
hint=('Ensure that your authentication backend can handle ' hint=('Ensure that your authentication backend(s) can handle '
'non-unique usernames.'), 'non-unique usernames.'),
obj=CustomUserNonUniqueUsername, obj=CustomUserNonUniqueUsername,
id='auth.W004', id='auth.W004',