mirror of
https://github.com/makeplane/plane
synced 2024-06-14 14:31:34 +00:00
chore: list of all views in workspace
This commit is contained in:
parent
4af5fef210
commit
1d88de472e
@ -63,7 +63,7 @@ class UserWorkspaceViewViewSet(BaseViewSet):
|
|||||||
super()
|
super()
|
||||||
.get_queryset()
|
.get_queryset()
|
||||||
.filter(workspace__slug=self.kwargs.get("slug"))
|
.filter(workspace__slug=self.kwargs.get("slug"))
|
||||||
.filter(project__isnull=True)
|
# .filter(project__isnull=True)
|
||||||
.filter(Q(owned_by=self.request.user) & Q(access=0))
|
.filter(Q(owned_by=self.request.user) & Q(access=0))
|
||||||
.select_related("workspace")
|
.select_related("workspace")
|
||||||
.annotate(is_favorite=Exists(subquery))
|
.annotate(is_favorite=Exists(subquery))
|
||||||
@ -86,6 +86,20 @@ class UserWorkspaceViewViewSet(BaseViewSet):
|
|||||||
{"error": "You cannot update the view"},
|
{"error": "You cannot update the view"},
|
||||||
status=status.HTTP_403_FORBIDDEN,
|
status=status.HTTP_403_FORBIDDEN,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def list(self, request, slug):
|
||||||
|
type = request.GET.get("type", None)
|
||||||
|
views = self.get_queryset()
|
||||||
|
|
||||||
|
if type == "workspace":
|
||||||
|
views = views.filter(project__isnull=True)
|
||||||
|
|
||||||
|
if type == "project":
|
||||||
|
views = views.filter(project__isnull=False)
|
||||||
|
|
||||||
|
serializer = ViewSerializer(views, many=True)
|
||||||
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
|
|
||||||
|
|
||||||
def toggle_lock(self, request, slug, pk):
|
def toggle_lock(self, request, slug, pk):
|
||||||
view = View.objects.get(pk=pk, workspace__slug=slug)
|
view = View.objects.get(pk=pk, workspace__slug=slug)
|
||||||
|
Loading…
Reference in New Issue
Block a user