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,6 +77,10 @@ class MovieManager(Manager):
exclude = False exclude = False
if keyType(k) == "string": if keyType(k) == "string":
if op == '=': if op == '=':
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 k = '%s__iexact' % k
elif op == '^': elif op == '^':
v = v[1:] v = v[1:]

View file

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