- if self.genres:
- book_genres = set([g['slug'] for g in audiobook.book['genres']])
- template_genres = set([g.strip() for g in self.genres.split(',')])
- if not book_genres.intersection(template_genres):
- return False
+ for category in 'authors', 'epochs', 'kinds', 'genres':
+ if getattr(self, category):
+ book_slugs = set([g['slug'] for g in audiobook.book[category]])
+ template_slugs = set([g.strip() for g in getattr(self, category).split(',')])
+ if not book_slugs.intersection(template_slugs):
+ return False