image in preview

This commit is contained in:
sanj 2011-01-19 14:11:55 +05:30
parent 4e5fdbe8a7
commit b42709604f
2 changed files with 7 additions and 3 deletions

View File

@ -57,7 +57,8 @@ class BestPractice(ItfModel):
for i in BestPracticeImage.objects.filter(bestpractice=self):
images.append({
'url': i.image.url,
'caption': i.caption
'caption': i.caption,
'thumb': i.get_thumb()
})
return images
@ -84,6 +85,9 @@ class BestPracticeImage(models.Model):
def __unicode__(self):
return self.caption
def get_thumb(self, max_width='200'):
return self.image.url #FIXME!!
class Guideline(models.Model):
title = models.CharField(max_length=512)
text = models.TextField()

View File

@ -2,7 +2,7 @@
<span class="itfPreviewTitle">${title}</span><br /><br />
<span class="itfPreviewSub">Category: </span><span class="itfPreviewText">${category}</span> <br /><br />
<div class="itfPreviewImages">
{{each images}} <img src="${$value.url}" title="${$value.caption}" /> {{/each}}
{{each images}} <img src="${$value.thumb}" width="200" title="${$value.caption}" /> {{/each}}
</div>
<span class="itfPreviewSub">Story: </span><span class="itfPreviewText">${story}</span>
</div>