Commits

Anonymous committed 136dd60

Added attribute inline to image admin
Added width/height fields

Comments (0)

Files changed (2)

gnocchi/gallery/admin.py

 admin.site.register(models.Gallery, GalleryAdmin)
 
 class ImageAdmin(admin.ModelAdmin):
-    list_display = ('thumb', 'gallery', 'image', 'name', 'order',)
-    list_filter = ('gallery', 'order',)
+    list_display = ('thumb', 'gallery', 'image', 'name', 'order', 'width', 'height',)
+    list_filter = ('gallery', 'order', 'width', 'height',)
     list_editable = ('order',)
+    inlines = [
+        InlineAttributeAdmin,
+    ]
 
     def thumb(self, obj):
         img = get_thumbnailer(obj.image).get_thumbnail({'size': (70, 70,)})

gnocchi/gallery/models.py

     return os.path.join('gallery', instance.gallery.slug, filename)
 
 class Image(models.Model, AttrHelper):
-    image = models.ImageField(upload_to=upload_to)
+    image = models.ImageField(upload_to=upload_to, width_field='width',
+        height_field='height')
     gallery = models.ForeignKey(Gallery, related_name='images')
     name = models.CharField(max_length=128, blank=True)
     order = models.IntegerField(default=0)
+    width = models.IntegerField(default=0)
+    height = model.IntegerField(default=0)
 
     attributes = generic.GenericRelation('tools.Attribute')
     tags = TaggableManager(blank=True)