Skip to content

Commit

Permalink
Make the custom stored libraries deletable
Browse files Browse the repository at this point in the history
  • Loading branch information
monsieurswag committed May 14, 2024
1 parent 4c9f4e3 commit f4fd33a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
16 changes: 16 additions & 0 deletions backend/library/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit f4fd33a

Please sign in to comment.