index more data

This commit is contained in:
j 2011-09-04 23:56:22 +02:00
parent 987ccf8af6
commit 53ce91b6bd

View file

@ -475,7 +475,7 @@ class Item(models.Model):
def save(key, value): def save(key, value):
f, created = ItemFind.objects.get_or_create(item=self, key=key) f, created = ItemFind.objects.get_or_create(item=self, key=key)
if value not in ('', ): if value not in ('', None):
if isinstance(value, basestring): if isinstance(value, basestring):
value = value.strip() value = value.strip()
f.value = value f.value = value
@ -483,9 +483,23 @@ class Item(models.Model):
else: else:
f.delete() f.delete()
#FIXME: use site_config for key in site_config()['itemKeys']:
save('title', u'\n'.join([self.get('title', 'Untitled'), if key.get('find'):
i = key['id']
if i == 'title':
save(i, u'\n'.join([self.get('title', 'Untitled'),
self.get('original_title', '')])) self.get('original_title', '')]))
elif i == 'filename':
save(i,
'\n'.join([os.path.join(f.folder, f.name) for f in self.files.all()]))
elif key['type'] == 'layer':
qs = Annotation.objects.filter(layer__name=i, item=self).order_by('start')
save(i, '\n'.join([l.value for l in qs]))
elif i != 'all' and i not in self.facet_keys:
value = self.get(i)
if isinstance(value, list):
value = u'\n'.join(value)
save(i, value)
for key in self.facet_keys: for key in self.facet_keys:
if key == 'character': if key == 'character':
@ -509,15 +523,6 @@ class Item(models.Model):
else: else:
save(key, values) save(key, values)
save('summary', self.get('summary', ''))
save('trivia', ' '.join(self.get('trivia', [])))
#FIXME:
qs = Annotation.objects.filter(layer__name='subtitles', item=self).order_by('start')
save('subtitles', '\n'.join([l.value for l in qs]))
save('filename', '\n'.join([u'%s/%s' % (f.folder, f.name) for f in self.files.all()]))
def update_sort(self): def update_sort(self):
try: try:
s = self.sort s = self.sort