Skip to content

Commit

Permalink
Merge pull request #11 from Kagiso-Future-Media/username
Browse files Browse the repository at this point in the history
Username wrapper for email field
  • Loading branch information
colinfrankb committed Jun 25, 2015
2 parents 6ec7de7 + d2580ff commit d01388f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
venv
tags
build
*.pyc
__pycache__
Expand Down
8 changes: 8 additions & 0 deletions auth_backend/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,14 @@ def get_full_name(self):
def get_short_name(self):
return self.email

@property
def username(self):
return self.email

@username.setter
def username(self, value):
self.email = value

def set_password(self, raw_password):
# We don't want to save passwords locally
self.set_unusable_password()
Expand Down
12 changes: 12 additions & 0 deletions auth_backend/tests/unit/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,18 @@ def test_set_password(self):

assert user.raw_password == password

def test_get_username_returns_email(self):
email = 'test@email.com'
user = models.KagisoUser(email=email)

assert user.username == email

def test_set_username_sets_username(self):
username = 'test@username.com'
user = models.KagisoUser(username=username)

assert user.email == username

@responses.activate
def test_confirm_email(self):
_, post_data = mocks.mock_out_post_users(1, 'test@email.com')
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='kagiso_django_auth',
version='0.1.2',
version='0.2.0',
author='Kagiso Media',
author_email='development@kagiso.io',
url='https://github.com/Kagiso-Future-Media/django_auth',
Expand Down

0 comments on commit d01388f

Please sign in to comment.