Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Fix API for getting organizations (HumanSignal#997)
Browse files Browse the repository at this point in the history
* Return organizations where user belongs to

* Add tests

Co-authored-by: nik <[email protected]>
  • Loading branch information
niklub and nik authored Jun 3, 2021
1 parent 4e1cb57 commit 8741d20
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion label_studio/organizations/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_object(self):
return org

def get_queryset(self):
return Organization.objects.filter(created_by=self.request.user)
return Organization.objects.filter(users=self.request.user).distinct()

@swagger_auto_schema(tags=['Organizations'])
def get(self, request, *args, **kwargs):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,11 @@ def test_active_organization_filled(business_client):
response = business_client.get('/api/users/')
response_data = response.json()
assert response_data[0]['active_organization'] == business_client.organization.id


@pytest.mark.django_db
def test_api_list_organizations(business_client):
response = business_client.get('/api/organizations/')
response_data = response.json()
assert len(response_data) == 1
assert response_data[0]['id'] == business_client.organization.id

0 comments on commit 8741d20

Please sign in to comment.