thumbnails

This commit is contained in:
Sanj 2011-10-05 19:54:04 +05:30
parent 38ea6a6fee
commit b72228dbb3
2 changed files with 15 additions and 6 deletions

View File

@ -42,7 +42,8 @@ class BestPractice(ItfModel):
'theatre': self.theatre, 'theatre': self.theatre,
'quick_howto': self.quick_howto, 'quick_howto': self.quick_howto,
'category': self.category.name, 'category': self.category.name,
'category_id': self.category.id 'category_id': self.category.id,
'images': self.get_images()
} }
def list_dict(self): def list_dict(self):
@ -64,11 +65,14 @@ class BestPractice(ItfModel):
def get_images(self): def get_images(self):
images = [] images = []
for i in BestPracticeImage.objects.filter(bestpractice=self): for i in BestPracticeImage.objects.filter(bestpractice=self):
images.append(i)
'''
images.append({ images.append({
'url': i.image.url, 'url': i.image.url,
'caption': i.caption, 'caption': i.caption,
'thumb': i.get_thumb() 'thumb': i.get_thumb()
}) })
'''
return images return images
''' '''
@ -93,7 +97,7 @@ class BestPracticeStory(models.Model):
def get_dict(self): def get_dict(self):
return { return {
'text': self.text, 'text': self.text,
'image': self.image.url if self.image.name != '' else '' 'image': self.image if self.image.name != '' else None
} }
class BestPracticeFAQ(ItfModel): class BestPracticeFAQ(ItfModel):

View File

@ -1,16 +1,21 @@
{% load thumbnail %}
<div class="itfInfo"> <div class="itfInfo">
{% for s in stories %} {% for s in stories %}
<span class="itfInfoSub">Story: </span><span class="ifInfoInfo">{{ s.text }}</span> <span class="itfInfoSub">Story: </span><span class="ifInfoInfo">{{ s.text }}</span>
<img class="itfInfoImg" src="{{ s.image }}" /> {% thumbnail s.image "100x100" crop="center" as im %}
<img class="itfInfoImg" src="{{ im.url }}" />
{% endthumbnail %}
<br /><br /> <br /><br />
{% endfor %} {% endfor %}
<span class="itfInfoSub">Law: </span><span class="itfInfoInfo">{{ law }}</span> <span class="itfInfoSub">Law: </span><span class="itfInfoInfo">{{ law }}</span>
{% if law_image %} {% if law_image %}
<img class="itfInfoImg" src="{{ law_image }}" /> {% thumbnail law_image "100x100" crop="center" as im %}
<img class="itfInfoImg" src="{{ im.url }}" />
{% endthumbnail %}
{% endif %} {% endif %}
<br /><br /> <br /><br />
<span class="itfInfoSub">Relevance to Theatre: </span><span class="itfInfoInfo">{{ theatre|linebreaks }}</span> <span class="itfInfoSub">Relevance to Theatre: </span><span class="itfInfoInfo">{{ theatre|linebreaksbr }}</span>
<span class="itfInfoSub">Quick Howto: </span><span class="itfInfoInfo">{{ quick_howto }}</span><br /><br /> <span class="itfInfoSub">Quick Howto: </span><span class="itfInfoInfo">{{ quick_howto|linebreaksbr }}</span><br /><br />
</div> </div>