Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DEV-3131: Fix user creating API #2801

Merged
merged 1 commit into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: DEV-3131: Fix user creating API
  • Loading branch information
triklozoid committed Aug 9, 2022
commit c65fb651d8f87a3855d5f5a5e5f10c4165e55ce8
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