mirror of
https://git.cmoser.eu/tinytools/django-tinywiki.git
synced 2026-02-04 06:06:33 +01:00
2025.12.27 13:33:05 (cachyos.cmoser.eu)
This commit is contained in:
@@ -25,13 +25,12 @@ class Command(BaseCommand):
|
||||
if not options['file']:
|
||||
raise CommandError("No file to import specified")
|
||||
|
||||
filename = Path(options['file'][0]).resolve()
|
||||
print(f"Importing from {filename} ...")
|
||||
|
||||
file = Path(options['file'][0]).resolve()
|
||||
print(f"Importing from {file} ...")
|
||||
|
||||
if not file.exists():
|
||||
if not filename.exists():
|
||||
raise CommandError("File does not exist!")
|
||||
if not file.is_file():
|
||||
if not filename.is_file():
|
||||
raise CommandError("Not a file!")
|
||||
|
||||
username = options['username']
|
||||
@@ -50,8 +49,8 @@ class Command(BaseCommand):
|
||||
except UserModel.DoesNotExist:
|
||||
raise CommandError(f"No user with email {email} exists.")
|
||||
|
||||
if zipfile.is_zipfile(file):
|
||||
with zipfile.ZipFile(file, "r") as zf:
|
||||
if zipfile.is_zipfile(filename):
|
||||
with zipfile.ZipFile(filename, "r") as zf:
|
||||
znames = zf.namelist()
|
||||
has_pages = 'pages.json' in znames
|
||||
has_images = 'images.json' in znames
|
||||
@@ -60,9 +59,9 @@ class Command(BaseCommand):
|
||||
raise CommandError("Not a valid zipfile!")
|
||||
|
||||
if has_pages:
|
||||
import_builtin_pages_from_zip(zip, user)
|
||||
import_builtin_pages_from_zip(filename, user)
|
||||
if has_images:
|
||||
import_builtin_images_from_zip(zip, user)
|
||||
import_builtin_images_from_zip(filename, user)
|
||||
else:
|
||||
with open(file, "rt", encoding="utf-8") as json_file:
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user