if gallery path doesn't exists, show empty gallery
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user