mirror of
https://github.com/Hopiu/django-imagekit.git
synced 2026-04-16 19:21:04 +00:00
Fixed indent and refactored ikflush command (issue #19)
This commit is contained in:
parent
eb97ed1180
commit
1d82a64bd7
1 changed files with 13 additions and 15 deletions
|
|
@ -20,19 +20,17 @@ def flush_cache(apps, options):
|
|||
"""
|
||||
apps = [a.strip(',') for a in apps]
|
||||
if apps:
|
||||
print 'Flushing cache for %s...' % ', '.join(apps)
|
||||
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:
|
||||
print 'Flushing cache for "%s.%s"' % (app_label, model.__name__)
|
||||
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()
|
||||
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()
|
||||
print 'Please specify on or more app names'
|
||||
|
|
|
|||
Loading…
Reference in a new issue