From 9edca050c8378485135588c30a657dac0af32661 Mon Sep 17 00:00:00 2001 From: Joshua Blum Date: Wed, 17 Jan 2018 20:19:20 -0500 Subject: [PATCH] Use get_username method instead of accessing username directly (#318) --- registration/models.py | 2 +- registration/templates/registration/password_reset_email.html | 2 +- registration/tests/admin_actions.py | 2 +- registration/tests/admin_approval_backend.py | 2 +- registration/tests/models.py | 4 ++-- test_app/templates/base.html | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/registration/models.py b/registration/models.py index 20d4d12b..e2ff9253 100644 --- a/registration/models.py +++ b/registration/models.py @@ -682,7 +682,7 @@ def send_admin_approve_complete_email(self, site, request=None): 'registration/admin_approve_complete_email.html') ctx_dict = { - 'user': self.user.username, + 'user': self.user.get_username(), 'site': site, } send_email( diff --git a/registration/templates/registration/password_reset_email.html b/registration/templates/registration/password_reset_email.html index 90b2f2cd..8653551b 100755 --- a/registration/templates/registration/password_reset_email.html +++ b/registration/templates/registration/password_reset_email.html @@ -17,7 +17,7 @@ {{ protocol }}://{{ domain }}{% url 'auth_password_reset_confirm' uid token %} -{% blocktrans %}Your username, in case you've forgotten:{% endblocktrans %} {{ user.username }} +{% blocktrans %}Your username, in case you've forgotten:{% endblocktrans %} {{ user.get_username }} {% blocktrans %}Best regards{% endblocktrans %}, diff --git a/registration/tests/admin_actions.py b/registration/tests/admin_actions.py index c3d178f1..6c41a4c1 100644 --- a/registration/tests/admin_actions.py +++ b/registration/tests/admin_actions.py @@ -24,7 +24,7 @@ def setUp(self): self.client = Client() admin_user = UserModel().objects.create_superuser( 'admin', 'admin@test.com', 'admin') - self.client.login(username=admin_user.username, password=admin_user) + self.client.login(username=admin_user.get_username(), password=admin_user) self.user_info = {'username': 'alice', 'password': 'swordfish', diff --git a/registration/tests/admin_approval_backend.py b/registration/tests/admin_approval_backend.py index 4627619c..7b4fc35d 100644 --- a/registration/tests/admin_approval_backend.py +++ b/registration/tests/admin_approval_backend.py @@ -43,7 +43,7 @@ def test_approval(self): kwargs={'activation_key': profile.activation_key})) admin_user = UserModel().objects.create_superuser('admin', 'admin@test.com', 'admin') - self.client.login(username=admin_user.username, password=admin_user) + self.client.login(username=admin_user.get_username(), password=admin_user) resp = self.client.get( reverse('registration_admin_approve', diff --git a/registration/tests/models.py b/registration/tests/models.py index dfff534f..bdc9398b 100644 --- a/registration/tests/models.py +++ b/registration/tests/models.py @@ -165,7 +165,7 @@ def test_user_creation(self): """ new_user = self.registration_profile.objects.create_inactive_user( site=Site.objects.get_current(), **self.user_info) - self.assertEqual(new_user.username, 'alice') + self.assertEqual(new_user.get_username(), 'alice') self.assertEqual(new_user.email, 'alice@example.com') self.failUnless(new_user.check_password('swordfish')) self.failIf(new_user.is_active) @@ -200,7 +200,7 @@ def test_user_creation_old_date_joined(self): """ new_user = self.registration_profile.objects.create_inactive_user( site=Site.objects.get_current(), **self.user_info) - self.assertEqual(new_user.username, 'alice') + self.assertEqual(new_user.get_username(), 'alice') self.assertEqual(new_user.email, 'alice@example.com') self.failUnless(new_user.check_password('swordfish')) self.failIf(new_user.is_active) diff --git a/test_app/templates/base.html b/test_app/templates/base.html index 172b3575..4877391a 100755 --- a/test_app/templates/base.html +++ b/test_app/templates/base.html @@ -12,7 +12,7 @@ {% trans "Home" %} | {% if user.is_authenticated %} - {% trans "Logged in" %}: {{ user.username }} + {% trans "Logged in" %}: {{ user.get_username }} ({% trans "Log out" %} | {% trans "Change password" %}) {% else %}