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 680dee3
Showing 1 changed file with 16 additions and 0 deletions.
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 680dee3

Please sign in to comment.