hacky exact match for lists

This commit is contained in:
j 2010-07-05 10:21:09 +02:00
parent 6c2358ed09
commit 305f38d0b7
2 changed files with 15 additions and 11 deletions

View file

@ -77,7 +77,11 @@ class MovieManager(Manager):
exclude = False
if keyType(k) == "string":
if op == '=':
k = '%s__iexact' % k
if k in ('director', 'country', 'language', 'genre', 'keywords', 'location', 'writer', 'producer', 'editor', 'cinematographer'):
k = '%s__icontains' % k
v = u'|%s|'%v
else:
k = '%s__iexact' % k
elif op == '^':
v = v[1:]
k = '%s__istartswith' % k

View file

@ -445,20 +445,20 @@ class Movie(models.Model):
f.title = self.get('title')
#FIXME: filter us/int title
#f.title += ' '.join([t.title for t in self.alternative_titles()])
f.director = ' '.join([i.name for i in self.directors()])
f.country = ' '.join([i.name for i in self.countries()])
f.director = '|%s|'%'|'.join([i.name for i in self.directors()])
f.country = '|%s|'%'|'.join([i.name for i in self.countries()])
f.year = self.get('year', '')
f.language = ' '.join([i.name for i in self.languages()])
f.writer = ' '.join([i.name for i in self.writers()])
f.producer = ' '.join([i.name for i in self.producers()])
f.editor = ' '.join([i.name for i in self.editors()])
f.cinematographer = ' '.join([i.name for i in self.cinematographers()])
f.language = '|%s|'%'|'.join([i.name for i in self.languages()])
f.writer = '|%s|'%'|'.join([i.name for i in self.writers()])
f.producer = '|%s|'%'|'.join([i.name for i in self.producers()])
f.editor = '|%s|'%'|'.join([i.name for i in self.editors()])
f.cinematographer = '|%s|'%'|'.join([i.name for i in self.cinematographers()])
f.cast = ' '.join(['%s %s' % i for i in self.cast()])
f.genre = ' '.join([i.name for i in self.genres()])
f.keywords = ' '.join([i.name for i in self.keywords()])
f.genre = '|%s|'%'|'.join([i.name for i in self.genres()])
f.keywords = '|%s|'%'|'.join([i.name for i in self.keywords()])
f.summary = self.get('plot', '') + self.get('plot_outline', '')
f.trivia = ' '.join([i.trivia for i in self.trivia()])
f.location = ' '.join([i.name for i in self.locations()])
f.location = '|%s|'%'|'.join([i.name for i in self.locations()])
#FIXME: collate filenames
#f.filename = self.filename
f.all = ' '.join(filter(None, [f.title, f.director, f.country, f.year, f.language,