Skip to content

Commit

Permalink
fix: DEV-3131: Fix user creating API (#2801)
Browse files Browse the repository at this point in the history
  • Loading branch information
triklozoid authored Aug 11, 2022
1 parent d54af98 commit 8197459
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
24 changes: 23 additions & 1 deletion label_studio/tests/users.tavern.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
test_name: test_ml_backend_creation
test_name: test_users
strict: false
marks:
- usefixtures:
Expand All @@ -21,3 +21,25 @@ stages:
url: '{django_live_url}/api/users/{user_pk}'
response:
status_code: 200
save:
json:
org_pk: active_organization
- name: stage
request:
json:
email: test_user@heartextest.com
username: test user
active_organization: !int '{org_pk}'
method: POST
url: '{django_live_url}/api/users'
response:
save:
json:
new_user_pk: id
status_code: 201
- name: stage
request:
method: GET
url: '{django_live_url}/api/users/{new_user_pk}'
response:
status_code: 200
4 changes: 4 additions & 0 deletions label_studio/users/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ def list(self, request, *args, **kwargs):
def create(self, request, *args, **kwargs):
return super(UserAPI, self).create(request, *args, **kwargs)

def perform_create(self, serializer):
instance = serializer.save()
self.request.user.active_organization.add_user(instance)

def retrieve(self, request, *args, **kwargs):
return super(UserAPI, self).retrieve(request, *args, **kwargs)

Expand Down

0 comments on commit 8197459

Please sign in to comment.