merging changes

This commit is contained in:
rolux 2011-08-07 02:44:24 +00:00
commit 3bbb46c98e

View file

@ -437,6 +437,8 @@ class Item(models.Model):
if 'reviews' in i: if 'reviews' in i:
i['reviews'] = self.reviews() i['reviews'] = self.reviews()
if not i['reviews']:
del i['reviews']
if 'cast' in i and isinstance(i['cast'][0], basestring): if 'cast' in i and isinstance(i['cast'][0], basestring):
i['cast'] = [i['cast']] i['cast'] = [i['cast']]
if 'cast' in i and isinstance(i['cast'][0], list): if 'cast' in i and isinstance(i['cast'][0], list):
@ -497,6 +499,12 @@ class Item(models.Model):
if isinstance(values[0], list): if isinstance(values[0], list):
values = map(lambda x: {'actor': x[0], 'character': x[1]}, values) values = map(lambda x: {'actor': x[0], 'character': x[1]}, values)
values = [i['character'] for i in values] values = [i['character'] for i in values]
elif key == 'name':
values = []
for k in map(lambda x: x['id'],
filter(lambda x: x.get('sort') == 'person',
config['itemKeys'])):
values += self.get(k, [])
else: else:
values = self.get(key, '') values = self.get(key, '')
if isinstance(values, list): if isinstance(values, list):
@ -504,6 +512,7 @@ class Item(models.Model):
else: else:
save(key, values) save(key, values)
save('summary', self.get('summary', '')) save('summary', self.get('summary', ''))
save('trivia', ' '.join(self.get('trivia', []))) save('trivia', ' '.join(self.get('trivia', [])))
@ -652,6 +661,13 @@ class Item(models.Model):
#FIXME: what to do with Unkown Director, Year, Country etc. #FIXME: what to do with Unkown Director, Year, Country etc.
for key in self.facet_keys: for key in self.facet_keys:
current_values = self.get(key, []) current_values = self.get(key, [])
#FIXME: is there a better way to build name collection?
if key == 'name':
current_values = []
for k in map(lambda x: x['id'],
filter(lambda x: x.get('sort') == 'person',
config['itemKeys'])):
current_values += self.get(k, [])
if not isinstance(current_values, list): if not isinstance(current_values, list):
current_values = [unicode(current_values)] current_values = [unicode(current_values)]
current_values = list(set(current_values)) current_values = list(set(current_values))