From 4bde77abccd15c0abe2df6ecd2779b4db80456fd Mon Sep 17 00:00:00 2001 From: j Date: Tue, 21 Jul 2020 14:49:34 +0200 Subject: [PATCH] rebuild posters --- .../management/commands/rebuild_posters.py | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 pandora/item/management/commands/rebuild_posters.py diff --git a/pandora/item/management/commands/rebuild_posters.py b/pandora/item/management/commands/rebuild_posters.py new file mode 100644 index 00000000..d22e4882 --- /dev/null +++ b/pandora/item/management/commands/rebuild_posters.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- + +import os +from glob import glob + +from django.core.management.base import BaseCommand + +import app.monkey_patch +from ... import models +from ... import tasks + +class Command(BaseCommand): + """ + rebuild posters for all items. + """ + help = 'rebuild all posters for all items.' + args = '' + + def handle(self, **options): + offset = 0 + chunk = 100 + count = models.Item.objects.count() + while offset <= count: + for i in models.Item.objects.all().order_by('id')[offset:offset+chunk]: + print(i) + if i.poster: + i.poster.delete() + i.make_poster() + offset += chunk