Skip to content

Commit

Permalink
added an API endpoint for excluding the guest workspaces where the u…
Browse files Browse the repository at this point in the history
…ser is already a part off
  • Loading branch information
ishangujarathi committed Feb 29, 2024
1 parent db75081 commit 070c2f9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion backend/workspaces/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,33 @@ def list_guest_workspaces(self, request):
{"message": "Error fetching guest workspaces."},
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
)

@action(
detail=False,
methods=["GET"],
name="Unauthenticated Guest Wroskapce",
url_path="list_unauthenticated_guest_workspaces",
)
def list_unauthenticated_guest_workspaces(self,request):
try:
workspaces = Workspace.objects.filter(members__in=[request.user.pk])
this_user_workspace_ids = workspaces.values_list('id',flat=True)
guest_workspaces = Workspace.objects.filter(guest_workspace=True).exclude(id__in = this_user_workspace_ids)
serializer = WorkspaceSerializer(guest_workspaces, many=True)
return Response(serializer.data, status = status.HTTP_200_OK)
except Exception as e:
return Response(
{"message": "Error Fetching guest workspace"},
status=status.HTTP_500_INTERNAL_SERVER_ERROR,
)

@action(
detail=True,
methods=["PUT"],
name="Guest Authentication",
url_path="guest_auth",
serializer_class=WorkspacePasswordSerializer,
)
)
def guest_auth(self, request, pk=None, *args, **kwargs):
"""
This endpoint is specifically designed for guest workspaces.
Expand Down

0 comments on commit 070c2f9

Please sign in to comment.