Browse Source

Move has_tiles to the panorama model

Baptiste Jonglez 10 years ago
parent
commit
988dbe3514
2 changed files with 4 additions and 5 deletions
  1. 0 5
      panorama/admin.py
  2. 4 0
      panorama/models.py

+ 0 - 5
panorama/admin.py

@@ -25,11 +25,6 @@ class PanoramaAdmin(admin.ModelAdmin):
     readonly_fields = ('image_width', 'image_height')
     actions = ('regenerate_tiles', )
 
-    def has_tiles(self, obj):
-        return path_exists(obj.tiles_dir()) and len(os.listdir(obj.tiles_dir())) > 0
-    #has_tiles.short_description = 'Name'
-    has_tiles.boolean = True
-
     def regenerate_tiles(self, request, queryset):
         for pano in queryset:
             pano.delete_tiles()

+ 4 - 0
panorama/models.py

@@ -132,6 +132,10 @@ class Panorama(ReferencePoint):
         return os.path.join(settings.MEDIA_URL, settings.PANORAMA_TILES_DIR,
                             str(self.pk))
 
+    def has_tiles(self):
+        return path_exists(self.tiles_dir()) and len(os.listdir(self.tiles_dir())) > 0
+    has_tiles.boolean = True
+
     def delete_tiles(self):
         """Delete all tiles and the tiles dir"""
         # If the directory doesn't exist, do nothing