Commits

Anonymous committed af99f34

Added upload_to method to keep image files organised
Reordered model fields for users
Allow tags to be blank

Comments (0)

Files changed (1)

gnocchi_gallery/models.py

 from django.db import models
+import os
 
 from gnocchi_tools.attr import AttrHelper
 from taggit.managers import TaggableManager
     def __unicode__(self):
         return self.name
 
+def upload_to(instance, filename):
+    return os.path.join('gallery', instance.gallery.slug, filename)
+
 class Image(models.Model, AttrHelper):
+    image = models.ImageField(upload_to=upload_to)
     gallery = models.ForeignKey(Gallery, related_name='images')
     name = models.CharField(max_length=128, blank=True)
-    description = models.TextField(blank=True)
-
-    image = models.ImageField(upload_to='gallery')
     order = models.IntegerField(default=0)
 
     attributes = generic.GenericRelation('gnocchi_tools.Attribute')
-    tags = TaggableManager()
+    tags = TaggableManager(blank=True)
 
     class Meta:
         ordering = ('order', 'id',)