Skip to content

Commit 1511484

Browse files
makseqMihajloHoma
andauthored
fix: DEV-3465: Projects, displayed on user's organization page, include other organizations (#3105)
Fix current user Co-authored-by: MihajloHoma <[email protected]>
1 parent 7c139c6 commit 1511484

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

label_studio/organizations/api.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,8 @@ class OrganizationMemberListAPI(generics.ListAPIView):
100100

101101
def get_serializer_context(self):
102102
return {
103-
'contributed_to_projects': bool_from_request(self.request.GET, 'contributed_to_projects', False)
103+
'contributed_to_projects': bool_from_request(self.request.GET, 'contributed_to_projects', False),
104+
'request': self.request
104105
}
105106

106107
def get_queryset(self):

label_studio/organizations/serializers.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,16 @@ def get_created_projects(self, user):
3636
if not self.context.get('contributed_to_projects', False):
3737
return None
3838

39-
return user.created_projects.filter(organization=user.active_organization).values('id', 'title')
39+
current_user = self.context['request'].user
40+
return user.created_projects.filter(organization=current_user.active_organization).values('id', 'title')
4041

4142
def get_contributed_to_projects(self, user):
4243
if not self.context.get('contributed_to_projects', False):
4344
return None
4445

46+
current_user = self.context['request'].user
4547
projects = user.annotations\
46-
.filter(task__project__organization=user.active_organization)\
48+
.filter(task__project__organization=current_user.active_organization)\
4749
.values('task__project__id', 'task__project__title')
4850
contributed_to = [(json.dumps({'id': p['task__project__id'], 'title': p['task__project__title']}), 0)
4951
for p in projects]

0 commit comments

Comments
 (0)