if gallery path doesn't exists, show empty gallery

This commit is contained in:
2022-03-06 12:42:59 +00:00
committed by Patrick Mayr
parent 34abb3acf3
commit bcffe6a683
2 changed files with 19 additions and 14 deletions

View File

@@ -47,8 +47,11 @@ def get_image_list(folder_name):
def get_folder_list():
if os.path.exists(settings.MEDIA_ROOT + "/" + gallery_path):
return next(os.walk(settings.MEDIA_ROOT + "/" + gallery_path))[1]
return None
def create_thumbs(folder_path):
file_path = os.path.join(settings.MEDIA_ROOT + "/" + gallery_path, folder_path)

View File

@@ -40,7 +40,9 @@ def index(request):
album.status = Album.DRAFT
if request.user.is_authenticated:
for folder in get_folder_list():
folders = get_folder_list()
if folders:
for folder in folders:
if not Album.objects.filter(folder_name=folder):
album = Album(
title=folder,