fix finding alternative titles fixes #2123

This commit is contained in:
j 2014-01-27 12:46:18 +00:00
parent aed67ea8f1
commit c5aefa2f00

View file

@ -697,17 +697,21 @@ class Item(models.Model):
else: else:
ItemFind.objects.filter(item=self, key=key).delete() ItemFind.objects.filter(item=self, key=key).delete()
with transaction.commit_on_success(): def get_titles():
for key in settings.CONFIG['itemKeys']:
i = key['id']
if i == 'title':
titles = [self.get('title', 'Untitled')] titles = [self.get('title', 'Untitled')]
if self.get('originalTitle'): if self.get('originalTitle'):
titles.append(self.get('originalTitle')) titles.append(self.get('originalTitle'))
at = self.get('alternativeTitles') at = self.get('alternativeTitles')
if at: if at:
titles += [a[0] for a in at] titles += [a[0] for a in at]
save(i, u'\n'.join(titles)) return titles
with transaction.commit_on_success():
for key in settings.CONFIG['itemKeys']:
i = key['id']
if i == 'title':
save(i, u'\n'.join(get_titles()))
elif i == 'rightslevel': elif i == 'rightslevel':
save(i, self.level) save(i, self.level)
elif i == 'filename': elif i == 'filename':
@ -729,7 +733,9 @@ class Item(models.Model):
save(i, value) save(i, value)
for key in self.facet_keys: for key in self.facet_keys:
if key == 'character': if i == 'title':
values = get_titles()
elif key == 'character':
values = self.get('cast', '') values = self.get('cast', '')
if values: if values:
values = filter(lambda x: x.strip(), values = filter(lambda x: x.strip(),