get main images
This commit is contained in:
parent
291fe9822f
commit
2449ade7c0
|
@ -115,6 +115,17 @@ class ItfModel(models.Model):
|
|||
return d
|
||||
|
||||
|
||||
def get_gallery_image(self):
|
||||
from mediagallery.models import Photo
|
||||
if self.galleries:
|
||||
qset = Photo.objects.filter(album__in=self.galleries.all())
|
||||
if qset.count() == 0:
|
||||
return None
|
||||
else:
|
||||
return qset[0].image
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_videos(self):
|
||||
from mediagallery.models import YoutubeVideo
|
||||
|
||||
|
@ -240,10 +251,11 @@ class ItfModel(models.Model):
|
|||
imgfield = self.get_modelextra().default_image
|
||||
|
||||
if imgfield:
|
||||
try:
|
||||
thumb = get_thumbnail(imgfield, size, crop="center").url
|
||||
except:
|
||||
thumb = 'http://placehold.it/%s' % size
|
||||
#try:
|
||||
thumb = get_thumbnail(imgfield, size, crop="center").url
|
||||
#except:
|
||||
# print imgfield.url
|
||||
# thumb = 'http://placehold.it/%s' % size
|
||||
else:
|
||||
thumb = 'http://placehold.it/%s' % size # Add default image for site
|
||||
return {
|
||||
|
|
|
@ -56,6 +56,9 @@ class Event(ItfModel):
|
|||
def get_title(self):
|
||||
return self.__unicode__()
|
||||
|
||||
def main_image(self):
|
||||
return self.image
|
||||
|
||||
def get_dict(self):
|
||||
# links = self.connections.all().order_by('link_type')
|
||||
# link_keys = self.connections.all().values_list['link_type'].distinct()
|
||||
|
|
|
@ -76,6 +76,9 @@ class Person(ItfModel):
|
|||
def get_title(self):
|
||||
return self.__unicode__()
|
||||
|
||||
def main_image(self):
|
||||
return self.image
|
||||
|
||||
def get_dict(self):
|
||||
#lconnections = [obj for obj in self.connections.all()]
|
||||
#rconnections = [ obj for obj in PersonPerson.objects.filter(person2=self)
|
||||
|
@ -435,6 +438,9 @@ class Production(ItfModel):
|
|||
return True
|
||||
return self.group.user_has_perms(user)
|
||||
|
||||
def main_image(self):
|
||||
return self.get_gallery_image()
|
||||
|
||||
def get_people(self):
|
||||
persons = [{"person":self.director, "role":"director", "assoc_type":'production', "assoc_name":self.name },
|
||||
{"person":self.playwright, "role":"playwright", "assoc_type":'production', "assoc_name":self.name }
|
||||
|
|
Loading…
Reference in New Issue
Block a user