diff --git a/backend/core/views.py b/backend/core/views.py index d308706860..e8fd309f74 100644 --- a/backend/core/views.py +++ b/backend/core/views.py @@ -67,6 +67,7 @@ def get_queryset(self): Folder.get_root_folder(), self.request.user, self.model )[0] queryset = self.model.objects.filter(id__in=object_ids_view) + return queryset def get_serializer_class(self): diff --git a/backend/library/views.py b/backend/library/views.py index b0b702ac4a..54aab536ca 100644 --- a/backend/library/views.py +++ b/backend/library/views.py @@ -53,6 +53,22 @@ def content(self, request, pk): lib = StoredLibrary.objects.get(id=pk) return Response(lib.content) + def destroy(self, request, *args, pk, **kwargs): + if not RoleAssignment.is_access_allowed( + user=request.user, + perm=Permission.objects.get(codename="delete_storedlibrary"), + folder=Folder.get_root_folder(), + ): + return Response(status=status.HTTP_403_FORBIDDEN) + + try: + lib = StoredLibrary.objects.get(urn=pk) + except: + return Response(data="Library not found.", status=status.HTTP_404_NOT_FOUND) + + lib.delete() + return Response(status=status.HTTP_204_NO_CONTENT) + @action(detail=True, methods=["get"], url_path="import") def import_library(self, request, pk): if not RoleAssignment.is_access_allowed(