This commit is contained in:
j 2011-10-20 10:43:33 +02:00
parent 3a420ab0c8
commit 0b30580e58

View file

@ -507,17 +507,16 @@ class Item(models.Model):
if key == 'character': if key == 'character':
values = self.get('cast', '') values = self.get('cast', '')
if values: if values:
if isinstance(values[0], basestring): values = filter(lambda x: x.strip(),
values = [values] [f['character'] for f in values])
if isinstance(values[0], list): values = list(set(values))
values = map(lambda x: {'actor': x[0], 'character': x[1]}, values)
values = [i['character'] for i in values]
elif key == 'name': elif key == 'name':
values = [] values = []
for k in map(lambda x: x['id'], for k in map(lambda x: x['id'],
filter(lambda x: x.get('sort') == 'person', filter(lambda x: x.get('sort') == 'person',
settings.CONFIG['itemKeys'])): settings.CONFIG['itemKeys'])):
values += self.get(k, []) values += self.get(k, [])
values = list(set(values))
else: else:
values = self.get(key, '') values = self.get(key, '')
if isinstance(values, list): if isinstance(values, list):
@ -547,27 +546,27 @@ class Item(models.Model):
setattr(s, name, value) setattr(s, name, value)
base_keys = ( base_keys = (
'id',
'aspectratio', 'aspectratio',
'bitrate',
'clips',
'cutsperminute',
'duration', 'duration',
'hue', 'hue',
'saturation', 'id',
'lightness', 'lightness',
'volume', 'modified',
'clips',
'numberofcuts', 'numberofcuts',
'cutsperminute',
'words',
'wordsperminute',
'resolution',
'pixels',
'size',
'bitrate',
'numberoffiles', 'numberoffiles',
'parts', 'parts',
'published', 'pixels',
'modified',
'popularity', 'popularity',
'published',
'resolution',
'saturation',
'size',
'volume',
'words',
'wordsperminute',
) )
for key in filter(lambda k: 'columnWidth' in k, settings.CONFIG['itemKeys']): for key in filter(lambda k: 'columnWidth' in k, settings.CONFIG['itemKeys']):
@ -623,9 +622,8 @@ class Item(models.Model):
s.published = self.published s.published = self.published
s.aspectratio = self.get('aspectRatio') s.aspectratio = self.get('aspectRatio')
# sort values based on data from videos s.words = sum([len(a.value.split()) for a in self.annotations.exclude(value='')])
s.words = sum([len(a.value.split()) for a in self.annotations.all()]) s.clips = self.clips.count()
s.clips= self.clips.count()
videos = self.files.filter(selected=True, is_video=True) videos = self.files.filter(selected=True, is_video=True)
if videos.count() > 0: if videos.count() > 0:
@ -671,7 +669,6 @@ class Item(models.Model):
s.save() s.save()
def update_facets(self): def update_facets(self):
#FIXME: what to do with Unkown Director, Year, Country etc.
for key in self.facet_keys + ['title']: for key in self.facet_keys + ['title']:
current_values = self.get(key, []) current_values = self.get(key, [])
if key == 'title': if key == 'title':
@ -682,9 +679,12 @@ class Item(models.Model):
ot = self.get('originalTitle') ot = self.get('originalTitle')
if ot: if ot:
current_values.append(ot) current_values.append(ot)
#FIXME: is there a better way to build name collection? elif key == 'character':
if key == 'name': current_values = filter(lambda x: x.strip(),
[f['character'] for f in self.get('cast', [])])
elif key == 'name':
current_values = [] current_values = []
#FIXME: is there a better way to build name collection?
for k in map(lambda x: x['id'], for k in map(lambda x: x['id'],
filter(lambda x: x.get('sort') == 'person', filter(lambda x: x.get('sort') == 'person',
settings.CONFIG['itemKeys'])): settings.CONFIG['itemKeys'])):