merged
This commit is contained in:
commit
cb69f1e3c3
|
@ -8,6 +8,7 @@ from django.template.loader import render_to_string
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from insidepages.models import ModuleTab, ModelExtra
|
||||
from os.path import exists
|
||||
from sorl.thumbnail import get_thumbnail
|
||||
|
||||
def splitSearch(string):
|
||||
ret = []
|
||||
|
@ -45,15 +46,19 @@ class ItfModel(models.Model):
|
|||
return self.get(self.title_field)
|
||||
|
||||
def get_tab(self):
|
||||
modelextra = self.get_modelextra()
|
||||
tab = ModuleTab.objects.filter(model=modelextra)[0]
|
||||
return tab
|
||||
|
||||
|
||||
def get_modelextra(self):
|
||||
try:
|
||||
ctype = ContentType.objects.get(model=self.__class__._meta.module_name)
|
||||
except:#FIXME: ideally catch only MultipleObjectsReturned (figure out where to import that from :/ ) #FUCKING way ugly hack to get clashing model ctype names with django internal models working (get_real_ctypes simply checks, if there are multiple content objects with the same 'module_name', which one is_itf_model, and returns that).
|
||||
ctype = get_real_ctype(self.__class__._meta.module_name)
|
||||
|
||||
# modelextra = ModelExtra.objects.filter(model=ctype)[0]
|
||||
modelextra = ctype.modelextra_set.all()[0]
|
||||
tab = ModuleTab.objects.filter(model=modelextra)[0]
|
||||
return tab
|
||||
return modelextra
|
||||
|
||||
def get_absolute_url(self):
|
||||
return "%s/?tab=%s&object_id=%d" % (self.get_module().get_absolute_url(), self.get_tab().slug, self.id)
|
||||
|
@ -68,11 +73,28 @@ class ItfModel(models.Model):
|
|||
|
||||
|
||||
def get_main_image(self):
|
||||
main_image = self.main_image()
|
||||
if main_image is not None:
|
||||
imgfield = main_image.image
|
||||
elif self.get_modelextra().default_image:
|
||||
imgfield = self.get_modelextra().default_image
|
||||
else:
|
||||
imgfield = None
|
||||
if imgfield is not None:
|
||||
try:
|
||||
thumb = get_thumbnail(imgfield, "142x150", crop="center").url
|
||||
except:
|
||||
thumb = ''
|
||||
else:
|
||||
thumb = ''
|
||||
return {
|
||||
'url': '',
|
||||
'caption': ''
|
||||
'thumb': thumb
|
||||
}
|
||||
|
||||
|
||||
def main_image(self):
|
||||
return None
|
||||
|
||||
def get_template_path(self):
|
||||
kls = self.__class__
|
||||
return "modules/%s/%s.html" % (kls._meta.app_label, kls._meta.module_name)
|
||||
|
|
|
@ -42,9 +42,13 @@ class BestPractice(ItfModel):
|
|||
'theatre': self.theatre,
|
||||
'quick_howto': self.quick_howto,
|
||||
'category': self.category.name,
|
||||
'category_id': self.category.id
|
||||
'category_id': self.category.id,
|
||||
'images': self.get_images()
|
||||
}
|
||||
|
||||
def main_image(self):
|
||||
return self.get_images()[0]
|
||||
|
||||
def list_dict(self):
|
||||
return {
|
||||
'id': self.id,
|
||||
|
@ -64,11 +68,14 @@ class BestPractice(ItfModel):
|
|||
def get_images(self):
|
||||
images = []
|
||||
for i in BestPracticeImage.objects.filter(bestpractice=self):
|
||||
images.append(i)
|
||||
'''
|
||||
images.append({
|
||||
'url': i.image.url,
|
||||
'caption': i.caption,
|
||||
'thumb': i.get_thumb()
|
||||
})
|
||||
'''
|
||||
return images
|
||||
|
||||
'''
|
||||
|
@ -93,7 +100,7 @@ class BestPracticeStory(models.Model):
|
|||
def get_dict(self):
|
||||
return {
|
||||
'text': self.text,
|
||||
'image': self.image.url if self.image.name != '' else ''
|
||||
'image': self.image if self.image.name != '' else None
|
||||
}
|
||||
|
||||
class BestPracticeFAQ(ItfModel):
|
||||
|
|
|
@ -14,6 +14,7 @@ $('#listLeft ul li a').live("click", function() {
|
|||
'tab': tab,
|
||||
'object_id': objId
|
||||
}, function(data) {
|
||||
$('#imageInside').css({'backgroundImage': 'url(' + data.main_image.thumb + ')'});
|
||||
$('#textRight').text(data.title).formatTitle();
|
||||
var searchTerm = $('.searchListField').val();
|
||||
var html = data.html;
|
||||
|
|
|
@ -1,16 +1,32 @@
|
|||
{% load thumbnail %}
|
||||
<div class="itfInfo">
|
||||
{% for s in stories %}
|
||||
<span class="itfInfoSub">Story: </span><span class="ifInfoInfo">{{ s.text }}</span>
|
||||
<img class="itfInfoImg" src="{{ s.image }}" />
|
||||
<br /><br />
|
||||
{% endfor %}
|
||||
<span class="itfInfoSub">Law: </span><span class="itfInfoInfo">{{ law }}</span>
|
||||
{% if law_image %}
|
||||
<img class="itfInfoImg" src="{{ law_image }}" />
|
||||
<span class="orange">Story: </span><span class="ifInfoInfo">{{ s.text }}</span>
|
||||
{% if s.image %}
|
||||
{% thumbnail s.image "100x100" crop="center" as im %}
|
||||
<img class="itfInfoImg" src="{{ im.url }}" />
|
||||
{% endthumbnail %}
|
||||
{% endif %}
|
||||
<br /><br />
|
||||
<span class="itfInfoSub">Relevance to Theatre: </span><span class="itfInfoInfo">{{ theatre|linebreaks }}</span>
|
||||
<span class="itfInfoSub">Quick Howto: </span><span class="itfInfoInfo">{{ quick_howto }}</span><br /><br />
|
||||
{% endfor %}
|
||||
<span class="orange">Law: </span><span class="itfInfoInfo">{{ law }}</span>
|
||||
{% if law_image %}
|
||||
{% thumbnail law_image "100x100" crop="center" as im %}
|
||||
<img class="itfInfoImg" src="{{ im.url }}" />
|
||||
{% endthumbnail %}
|
||||
{% endif %}
|
||||
<br /><br />
|
||||
<span class="orange">Relevance to Theatre: </span><span class="itfInfoInfo">{{ theatre|linebreaksbr }}</span> <br /><br />
|
||||
<span class="orange">Quick Howto: </span><span class="itfInfoInfo">{{ quick_howto|linebreaksbr }}</span><br /><br />
|
||||
|
||||
<div class="thumbsGallery">
|
||||
{% for img in images %}
|
||||
{% thumbnail img.image "100x100" crop="center" as im %}
|
||||
<img class="itfInfoImg" src="{{ im.url }}" class="thumbsDetails" />
|
||||
{% endthumbnail %}
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
|
||||
<div id="imageLeft">
|
||||
<div id="imageInside">
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user