From 305f38d0b7bee932b182846b797a986d0d79cb10 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 5 Jul 2010 10:21:09 +0200 Subject: [PATCH] hacky exact match for lists --- pandora/backend/managers.py | 6 +++++- pandora/backend/models.py | 20 ++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pandora/backend/managers.py b/pandora/backend/managers.py index 737e3d439..215094d9b 100644 --- a/pandora/backend/managers.py +++ b/pandora/backend/managers.py @@ -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 diff --git a/pandora/backend/models.py b/pandora/backend/models.py index 7b4c7c832..9af3c441b 100644 --- a/pandora/backend/models.py +++ b/pandora/backend/models.py @@ -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,