From 9b05138a4932a8071e1757986e5723fa59b2bd4a Mon Sep 17 00:00:00 2001 From: James Socol Date: Thu, 14 Jan 2010 15:26:46 -0800 Subject: [PATCH] put amo.email into django.user.username --- apps/cake/tests.py | 2 +- apps/users/models.py | 2 +- apps/users/tests/test_models.py | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/apps/cake/tests.py b/apps/cake/tests.py index 886e69b629..e7f48adab7 100644 --- a/apps/cake/tests.py +++ b/apps/cake/tests.py @@ -28,7 +28,7 @@ class CakeTestCase(TestCase): self.assertEqual(profile.firstname, user.first_name) self.assertEqual(profile.lastname, user.last_name) - self.assertEqual(profile.nickname, user.username) + self.assertEqual(profile.email, user.username) self.assertEqual(profile.email, user.email) self.assertEqual(profile.created, user.date_joined) self.assertEqual(profile.password, user.password) diff --git a/apps/users/models.py b/apps/users/models.py index f5f75d73c9..4d1e0842f4 100644 --- a/apps/users/models.py +++ b/apps/users/models.py @@ -110,7 +110,7 @@ class UserProfile(amo.ModelBase): self.user = User(id=self.pk) self.user.first_name = self.firstname self.user.last_name = self.lastname - self.user.username = self.nickname + self.user.username = self.email self.user.email = self.email self.user.password = self.password self.user.date_joined = self.created diff --git a/apps/users/tests/test_models.py b/apps/users/tests/test_models.py index 9a65fdde58..2914dd9c6e 100644 --- a/apps/users/tests/test_models.py +++ b/apps/users/tests/test_models.py @@ -1,3 +1,4 @@ +from datetime import datetime import hashlib from django import test @@ -23,6 +24,14 @@ def test_welcome_name(): eq_(u4.welcome_name, '') +def test_empty_nickname(): + u = UserProfile(email='yoyoyo@yo.yo', pk=1, created=datetime.now()) + assert u.user is None + u.create_django_user() + assert u.user is not None + eq_(u.user.username, 'yoyoyo@yo.yo') + + def test_resetcode_expires(): """ For some reasone resetcode is required, and we default it to @@ -32,7 +41,7 @@ def test_resetcode_expires(): """ u = UserProfile(lastname='Connor', pk=2, resetcode_expires=None, - email='j.connor@sky.net') + nickname='fffuuu', email='j.connor@sky.net') u.save() assert u.resetcode_expires