fix: Add image before checking files

This commit is contained in:
Nathan Woodburn 2024-02-25 14:23:45 +11:00
parent ed222714ce
commit 96f7f0fece
Signed by: nathanwoodburn
GPG Key ID: 203B000478AD0EF1

View File

@ -204,6 +204,7 @@ def site_post():
address = [i for i in address if i['address'] != ''] address = [i for i in address if i['address'] != '']
data['address'] = address data['address'] = address
data['image'] = ''
if 'image' in request.files: if 'image' in request.files:
if request.files['image'].filename != '' and request.files['image'].filename != None: if request.files['image'].filename != '' and request.files['image'].filename != None:
# Make sure the file is an image # Make sure the file is an image
@ -212,8 +213,6 @@ def site_post():
file.save(f'avatars/{i["name"]}.' + extension) file.save(f'avatars/{i["name"]}.' + extension)
data['image'] = f'{i["name"]}.' + extension data['image'] = f'{i["name"]}.' + extension
else:
data['image'] = ''
with open(f'sites/{i["name"]}.json', 'w') as file: with open(f'sites/{i["name"]}.json', 'w') as file: