Skip to content

Commit

Permalink
fix: LEAP-626: Fix serialization for user without org member (HumanSi…
Browse files Browse the repository at this point in the history
…gnal#5500)

Co-authored-by: nikitabelonogov <[email protected]>
Co-authored-by: triklozoid <[email protected]>
  • Loading branch information
3 people authored Feb 28, 2024
1 parent d7ab6e8 commit 4e8a2f7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion label_studio/users/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"""
from core.feature_flags import flag_set
from core.utils.common import load_func
from core.utils.db import fast_first
from django.conf import settings
from organizations.models import OrganizationMember
from rest_flex_fields import FlexFieldsModelSerializer
Expand Down Expand Up @@ -46,7 +47,11 @@ def _is_deleted(self, instance):
if not org_id:
return False

organization_member_for_user = OrganizationMember.objects.get(user_id=instance.id, organization_id=org_id)
organization_member_for_user = fast_first(
OrganizationMember.objects.filter(user_id=instance.id, organization_id=org_id)
)
if not organization_member_for_user:
return True
return bool(organization_member_for_user.deleted_at)

def to_representation(self, instance):
Expand Down

0 comments on commit 4e8a2f7

Please sign in to comment.