Commit 6463bcae by jsa

user_api: get username into user object

so it can be used to generate unsubscribe tokens
parent 50ef0d1c
...@@ -14,8 +14,8 @@ class UserSerializer(serializers.HyperlinkedModelSerializer): ...@@ -14,8 +14,8 @@ class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta: class Meta:
model = User model = User
# This list is the minimal set required by the notification service # This list is the minimal set required by the notification service
fields = ("id", "email", "name") fields = ("id", "email", "name", "username")
read_only_fields = ("id", "email") read_only_fields = ("id", "email", "username")
class UserPreferenceSerializer(serializers.HyperlinkedModelSerializer): class UserPreferenceSerializer(serializers.HyperlinkedModelSerializer):
......
...@@ -74,7 +74,7 @@ class UserApiTestCase(TestCase): ...@@ -74,7 +74,7 @@ class UserApiTestCase(TestCase):
def assertUserIsValid(self, user): def assertUserIsValid(self, user):
"""Assert that the given user result is valid""" """Assert that the given user result is valid"""
self.assertItemsEqual(user.keys(), ["email", "id", "name", "url"]) self.assertItemsEqual(user.keys(), ["email", "id", "name", "username", "url"])
self.assertSelfReferential(user) self.assertSelfReferential(user)
def assertPrefIsValid(self, pref): def assertPrefIsValid(self, pref):
...@@ -196,7 +196,8 @@ class UserViewSetTest(UserApiTestCase): ...@@ -196,7 +196,8 @@ class UserViewSetTest(UserApiTestCase):
"email": user.email, "email": user.email,
"id": user.id, "id": user.id,
"name": user.profile.name, "name": user.profile.name,
"url": uri, "username": user.username,
"url": uri
} }
) )
...@@ -334,6 +335,7 @@ class UserPreferenceViewSetTest(UserApiTestCase): ...@@ -334,6 +335,7 @@ class UserPreferenceViewSetTest(UserApiTestCase):
"email": pref.user.email, "email": pref.user.email,
"id": pref.user.id, "id": pref.user.id,
"name": pref.user.profile.name, "name": pref.user.profile.name,
"username": pref.user.username,
"url": self.get_uri_for_user(pref.user), "url": self.get_uri_for_user(pref.user),
}, },
"key": pref.key, "key": pref.key,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment