1. Davor Lucic
  2. django-imagekit

Commits

Justin Driscoll  committed 3f4a682

Fixed indent and refactored ikflush command (issue #19)

  • Participants
  • Parent commits 861930c
  • Branches default

Comments (0)

Files changed (1)

File imagekit/management/commands/ikflush.py

View file
     """
     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'