Skip to content
This repository has been archived by the owner on Jan 19, 2021. It is now read-only.

Commit

Permalink
[fix bug 920657] Distinct() users in API results.
Browse files Browse the repository at this point in the history
  • Loading branch information
glogiotatidis committed Sep 26, 2013
1 parent b643a85 commit cf45972
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mozillians/users/api.py
Expand Up @@ -277,4 +277,4 @@ def apply_filters(self, request, applicable_filters):
if request.GET.get('restricted', False):
mega_filter &= Q(allows_community_sites=True)

return UserProfile.objects.complete().filter(mega_filter).order_by('id')
return UserProfile.objects.complete().filter(mega_filter).distinct().order_by('id')
14 changes: 14 additions & 0 deletions mozillians/users/tests/test_api.py
Expand Up @@ -509,3 +509,17 @@ def test_only_completed_profiles(self):
eq_(len(data['objects']), 2)
for obj in data['objects']:
ok_(obj['email'] != user.email)

def test_distinct_results(self):
user = UserFactory.create(userprofile={'is_vouched': True})
group_1 = GroupFactory.create()
group_2 = GroupFactory.create()
group_1.members.add(user.userprofile)
group_2.members.add(user.userprofile)
client = Client()
url = urlparams(self.mozilla_resource_url,
groups=','.join([group_1.name, group_2.name]))
response = client.get(url, follow=True)
data = json.loads(response.content)
eq_(response.status_code, 200)
eq_(len(data['objects']), 1)

0 comments on commit cf45972

Please sign in to comment.