Skip to content

Commit

Permalink
Use get_username method instead of accessing username directly (#318)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblum authored Jan 18, 2018
1 parent bbf5e08 commit 9edca05
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion registration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{{ protocol }}://{{ domain }}{% url 'auth_password_reset_confirm' uid token %}
</a>

{% 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 %},
Expand Down
2 changes: 1 addition & 1 deletion registration/tests/admin_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
2 changes: 1 addition & 1 deletion registration/tests/admin_approval_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
4 changes: 2 additions & 2 deletions registration/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion test_app/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<a href="{% url 'index' %}">{% trans "Home" %}</a> |

{% if user.is_authenticated %}
{% trans "Logged in" %}: {{ user.username }}
{% trans "Logged in" %}: {{ user.get_username }}
(<a href="{% url 'auth_logout' %}">{% trans "Log out" %}</a> |
<a href="{% url 'auth_password_change' %}">{% trans "Change password" %}</a>)
{% else %}
Expand Down

0 comments on commit 9edca05

Please sign in to comment.