summaryrefslogtreecommitdiffstats
path: root/imagekit/management/commands/ikflush.py
diff options
context:
space:
mode:
authorPhilip Sargent <philip.sargent@klebos.com>2020-05-26 02:19:46 +0100
committerPhilip Sargent <philip.sargent@klebos.com>2020-05-26 02:19:46 +0100
commit6ae5c0d912dfa9cfbf7dea8af2440b6bc8872bdd (patch)
treef9c9de7dcb2b9a41ec1aefda1b575183f86dfcb4 /imagekit/management/commands/ikflush.py
parent44d190e91c32b85f717eb8f5080113ba17cea3d4 (diff)
downloadtroggle-6ae5c0d912dfa9cfbf7dea8af2440b6bc8872bdd.tar.gz
troggle-6ae5c0d912dfa9cfbf7dea8af2440b6bc8872bdd.tar.bz2
troggle-6ae5c0d912dfa9cfbf7dea8af2440b6bc8872bdd.zip
remove old imagekit files
Diffstat (limited to 'imagekit/management/commands/ikflush.py')
-rw-r--r--imagekit/management/commands/ikflush.py38
1 files changed, 0 insertions, 38 deletions
diff --git a/imagekit/management/commands/ikflush.py b/imagekit/management/commands/ikflush.py
deleted file mode 100644
index 0af60c4..0000000
--- a/imagekit/management/commands/ikflush.py
+++ /dev/null
@@ -1,38 +0,0 @@
-from django.db.models.loading import cache
-from django.core.management.base import BaseCommand, CommandError
-from optparse import make_option
-from imagekit.models import ImageModel
-from imagekit.specs import ImageSpec
-
-
-class Command(BaseCommand):
- help = ('Clears all ImageKit cached files.')
- args = '[apps]'
- requires_model_validation = True
- can_import_settings = True
-
- def handle(self, *args, **options):
- return flush_cache(args, options)
-
-def flush_cache(apps, options):
- """ Clears the image cache
-
- """
- apps = [a.strip(',') for a in apps]
- if apps:
- print('Flushing cache for %s...' % ', '.join(apps))
- else:
- print('Flushing caches...')
-
- for app_label in apps:
- app = cache.get_app(app_label)
- models = [m for m in cache.get_models(app) if issubclass(m, ImageModel)]
-
- for model in models:
- for obj in model.objects.all():
- for spec in model._ik.specs:
- prop = getattr(obj, spec.name(), None)
- if prop is not None:
- prop._delete()
- if spec.pre_cache:
- prop._create()