Fix folder path logic error

This commit is contained in:
Renato 2023-09-13 13:26:39 +08:00
parent 32343df22e
commit 563c7f2219

View File

@ -1001,10 +1001,14 @@ class FilesAndFoldersViewSet(ReadOnlyModelViewSet):
# parent_folder = request.query_params.get('path__istartswith', '')
if parent_storage_path_id:
folders = []
parent_storage_path = StoragePath.objects.get(id=parent_storage_path_id)
folders = list(StoragePath.objects
child_folders = list(StoragePath.objects
.filter(path__istartswith=parent_storage_path.path)
.exclude(id=parent_storage_path.id))
for f in child_folders:
if len(f.path.replace(parent_storage_path.path, '').split('/')) == 2:
folders.append(f)
files = list(Document.objects.all().filter(storage_path=parent_storage_path).order_by(ordering))
else:
folders = list(StoragePath.objects.exclude(path__contains='/'))