Skip to content

Commit

Permalink
Revert "Update views.py"
Browse files Browse the repository at this point in the history
  • Loading branch information
ishvindersethi22 authored Jul 3, 2024
1 parent da339bb commit 848d2c3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
15 changes: 5 additions & 10 deletions backend/projects/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1290,8 +1290,7 @@ def list_optimized(self, request):
List all projects with some optimizations.
"""
try:
if "guest_view" not in request.query_params:
projects = self.queryset.filter(annotators=request.user)
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 @@ -1323,12 +1322,6 @@ 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 @@ -1376,9 +1369,11 @@ 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)
included_projects = projects.exclude(annotators=request.user)
excluded_projects = projects.filter(annotators=request.user)
included_projects_serialized = ProjectSerializerOptimized(
included_projects, many=True
)
Expand Down
10 changes: 5 additions & 5 deletions backend/workspaces/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ def enter_workspace(self, request, pk=None):
workspace.members.add(request.user)
workspace.save()

#projects = Project.objects.filter(workspace_id=workspace.id)
#for project in projects:
# project.annotators.add(request.user)
# project.save()
projects = Project.objects.filter(workspace_id=workspace.id)
for project in projects:
project.annotators.add(request.user)
project.save()

return Response(
{
"message": "User added to the workspace."
"message": "User added to the workspace and projects as an annotator."
},
status=status.HTTP_200_OK,
)
Expand Down

0 comments on commit 848d2c3

Please sign in to comment.