fix error for models without galleries attr

This commit is contained in:
Sanjay B 2015-08-02 16:07:50 +05:30
parent ce6680f8b0
commit 85e6d5f524
2 changed files with 5 additions and 5 deletions

View File

@ -132,7 +132,7 @@ class ItfModel(models.Model):
def get_gallery_image(self):
from mediagallery.models import Photo
if self.galleries:
if hasattr(self, 'galleries'):
qset = Photo.objects.filter(album__in=self.galleries.all())
if qset.count() == 0:
return None
@ -144,7 +144,7 @@ class ItfModel(models.Model):
def get_videos(self):
from mediagallery.models import YoutubeVideo
if self.galleries:
if hasattr(self, 'galleries'):
qset = YoutubeVideo.objects.filter(album__in=self.galleries.all())
if qset.count() == 0:
return False

View File

@ -130,9 +130,9 @@ class Person(ItfModel):
}
def related_scripts(self):
prod_scripts = [ p.script for p in self.productions.all() ]
prod_scripts.extend( [ p.script for p in self.productions_authored.all() ] )
prod_scripts.extend( [ p.script for p in self.productions_directed.all() ] )
#prod_scripts = [ p.script for p in self.productions.all() ]
prod_scripts = [ p.script for p in self.productions_authored.all() ]
#prod_scripts.extend( [ p.script for p in self.productions_directed.all() ] )
#auth_scripts = Script.objects.filter(author__iexact=)
return prod_scripts