Skip to content

Commit

Permalink
[#2364] Fix UserSerializer.get_user_profile() for users without organ…
Browse files Browse the repository at this point in the history
…isation
  • Loading branch information
zzgvh committed Sep 16, 2016
1 parent 3155bd9 commit 8a52019
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion akvo/rest/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def __init__(self, *args, **kwargs):
def get_user_profile(self, obj):
""" The Tastypie endpoint included the organisation ID in a separate sub-object
"""
return {"object": "/api/v1/organisation/{}/".format(obj.first_organisation().id)}
if obj.first_organisation():
return {"object": "/api/v1/organisation/{}/".format(obj.first_organisation().id)}
return None

def get_username(self, obj):
return obj.email
Expand Down

0 comments on commit 8a52019

Please sign in to comment.