use instance name if possible

This commit is contained in:
j 2011-04-08 10:20:59 +02:00
parent c7eb267f15
commit 224055c7bb
2 changed files with 4 additions and 2 deletions

View file

@ -297,6 +297,7 @@ class File(models.Model):
return 'unknown'
def get_instance(self):
#FIXME: what about other instances?
if self.instances.all().count() > 0:
return self.instances.all()[0]
return None
@ -318,7 +319,8 @@ class File(models.Model):
return u''
def get_name(self):
if self.is_extra:
instance = self.get_instance()
if instance:
return self.get_instance().name
if self.item:
name = self.item.get('title', 'Untitled')

View file

@ -226,7 +226,7 @@ Positions
response['data']['items'] = [only_p(m['json']) for m in qs.values('json')]
else: # otherwise stats
items = query['qs']
files = File.objects.all().filter(item__in=items).filter(size__gt=0)
files = File.objects.filter(item__in=items).filter(size__gt=0)
r = files.aggregate(
Sum('duration'),
Sum('pixels'),