Skip to content

Commit

Permalink
add a related_names to the gallery's images
Browse files Browse the repository at this point in the history
  • Loading branch information
Lacrymology committed Jun 20, 2013
1 parent 461b0bb commit 2b27831
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion cmsplugin_s3slider/cms_plugins.py
Expand Up @@ -16,7 +16,7 @@ class CMSGalleryPlugin(CMSPluginBase):

def render(self, context, instance, placeholder):
context.update({
'images': instance.image_set.all(),
'images': instance.images.all(),
'gallery': instance,
'slider_id': "slider%d"%instance.pk,
})
Expand Down
10 changes: 5 additions & 5 deletions cmsplugin_s3slider/models.py
Expand Up @@ -32,21 +32,21 @@ class GalleryPlugin(CMSPlugin):
default='left')

def width(self):
return max([i.src_width for i in self.image_set.all()])
return max([i.src_width for i in self.images.all()])
def height(self):
return max([i.src_height for i in self.image_set.all()])
return max([i.src_height for i in self.images.all()])

def __unicode__(self):
return _(u'%(count)d image(s) in gallery') % {
'count': self.image_set.count()
'count': self.images.count()
}


class Image(Orderable):
def get_media_path(self, filename):
return self.gallery.get_media_path(filename)

gallery = models.ForeignKey(GalleryPlugin)
gallery = models.ForeignKey(GalleryPlugin, related_name='images')
image = models.ImageField(upload_to=get_media_path,
height_field='src_height',
width_field='src_width', blank=True, null=True,
Expand Down

0 comments on commit 2b27831

Please sign in to comment.