Skip to content

Commit

Permalink
Update views.py
Browse files Browse the repository at this point in the history
  • Loading branch information
ishvindersethi22 authored Jul 3, 2024
1 parent a93f0cb commit 11d717c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions backend/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,8 @@ def list_optimized(self, request):
List all projects with some optimizations.
"""
try:
projects = self.queryset.filter(annotators=request.user)
if "guest_view" not in request.query_params:
projects = self.queryset.filter(annotators=request.user)
if request.user.is_superuser:
projects = self.queryset
elif request.user.role == User.ORGANIZATION_OWNER:
Expand Down Expand Up @@ -1322,6 +1323,12 @@ def list_optimized(self, request):
elif request.user.role == User.ANNOTATOR:
projects = self.queryset.filter(annotators=request.user)
projects = projects.filter(is_published=True).filter(is_archived=False)
if "guest_workspace_filter" in request.query_params:
projects = self.queryset.filter(workspace_id__guest_workspace=True).filter(
workspace_id__in=Workspace.objects.filter(
members=request.user
).values_list("id", flat=True)
)

if "project_user_type" in request.query_params:
project_user_type = request.query_params["project_user_type"]
Expand Down Expand Up @@ -1369,8 +1376,6 @@ def list_optimized(self, request):
else:
projects = projects.order_by(F("published_at").desc(nulls_last=True))

if "guest_workspace_filter" in request.query_params:
projects = projects.filter(workspace_id__guest_workspace=True)
if "guest_view" in request.query_params:
included_projects = projects.filter(annotators=request.user)
excluded_projects = projects.exclude(annotators=request.user)
Expand Down

0 comments on commit 11d717c

Please sign in to comment.