From fda2565e7778d3eaf010565d7a5a785c591b8239 Mon Sep 17 00:00:00 2001 From: Trevor Peacock Date: Wed, 30 Jan 2019 14:46:28 +1100 Subject: [PATCH] update minor change requests --- src/wiki/forms.py | 18 ++++++++++++++++++ src/wiki/forms_account_handling.py | 6 +++--- tests/core/test_checks.py | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/wiki/forms.py b/src/wiki/forms.py index 0dfe8276..9a8fa0bb 100644 --- a/src/wiki/forms.py +++ b/src/wiki/forms.py @@ -1,3 +1,21 @@ + +__all__ = [ + 'UserCreationForm', + 'UserUpdateForm', + 'WikiSlugField', + 'SpamProtectionMixin', + 'CreateRootForm', + 'MoveForm', + 'EditForm', + 'SelectWidgetBootstrap', + 'TextInputPrepend', + 'CreateForm', + 'DeleteForm', + 'PermissionsForm', + 'DirFilterForm', + 'SearchForm', +] + from datetime import timedelta from django import forms diff --git a/src/wiki/forms_account_handling.py b/src/wiki/forms_account_handling.py index 9dde51b5..ff1757d2 100644 --- a/src/wiki/forms_account_handling.py +++ b/src/wiki/forms_account_handling.py @@ -21,18 +21,18 @@ def _get_field(model, field): User = get_user_model() -def check_user_field(user_model=User): +def check_user_field(user_model): return isinstance(_get_field(user_model, user_model.USERNAME_FIELD), CharField) -def check_email_field(user_model=User): +def check_email_field(user_model): return isinstance(_get_field(user_model, user_model.get_email_field_name()), EmailField) # django parses the ModelForm (and Meta classes) on class creation, which fails with custom models without expected fields. # We need to check this here, because if this module can't load then system checks can't run. CustomUser = User \ - if (settings.ACCOUNT_HANDLING and check_user_field() and check_email_field()) \ + if (settings.ACCOUNT_HANDLING and check_user_field(User) and check_email_field(User)) \ else django.contrib.auth.models.User diff --git a/tests/core/test_checks.py b/tests/core/test_checks.py index 383a3fc5..07acf8b7 100644 --- a/tests/core/test_checks.py +++ b/tests/core/test_checks.py @@ -54,7 +54,7 @@ class CheckTests(TestCase): from django.core.exceptions import FieldError from django import forms from ..testdata.models import VeryCustomUser - with self.assertRaisesRegex(FieldError, 'Unknown field\(s\) \((email|username|, )+\) specified for VeryCustomUser'): + with self.assertRaisesRegex(FieldError, 'Unknown field\\(s\\) \\((email|username|, )+\\) specified for VeryCustomUser'): class UserUpdateForm(forms.ModelForm): class Meta: model = VeryCustomUser -- 2.45.2