From 4f6abae5b31bbec627dcab3923600899cb1ef0d6 Mon Sep 17 00:00:00 2001 From: Patrick Mayr Date: Sat, 1 Jan 2022 23:34:41 +0000 Subject: [PATCH] add cmd --- Readme.md | 5 +++++ fet2020/gallery/management/__init__.py | 0 .../gallery/management/commands/__init__.py | 0 .../management/commands/create_thumbs.py | 19 +++++++++++++++++++ 4 files changed, 24 insertions(+) create mode 100644 fet2020/gallery/management/__init__.py create mode 100644 fet2020/gallery/management/commands/__init__.py create mode 100644 fet2020/gallery/management/commands/create_thumbs.py diff --git a/Readme.md b/Readme.md index 7d5c933d..a6af4680 100644 --- a/Readme.md +++ b/Readme.md @@ -26,4 +26,9 @@ git clone https://git.fet.at/bofh/fet2020 {{docker-compose.yml}} docker-compose up + + +Beim erstmaligen Erstellen der Thumbs für die Galerie soll dieser Command ausgeführt werden: + +python3 fet2020/manage.py create_thumbs \ No newline at end of file diff --git a/fet2020/gallery/management/__init__.py b/fet2020/gallery/management/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/fet2020/gallery/management/commands/__init__.py b/fet2020/gallery/management/commands/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/fet2020/gallery/management/commands/create_thumbs.py b/fet2020/gallery/management/commands/create_thumbs.py new file mode 100644 index 00000000..95da0b3a --- /dev/null +++ b/fet2020/gallery/management/commands/create_thumbs.py @@ -0,0 +1,19 @@ +import logging +import os + +from django.core.management.base import BaseCommand + +from gallery.utils import create_thumbs + + +logger = logging.getLogger(__name__) + +class Command(BaseCommand): + def handle(self, *args, **options): + _base_dir = "/home/project/fet2020/fet2020" + _path = "/files/uploads/gallery" + + folders = next(os.walk(_base_dir + _path))[1] + for folder in folders: + logger.info(f"Ordner {folder} wird bearbeitet.") + create_thumbs(folder)