$def with(work)
$if work and not is_bot():
$ subjects = work.get_related_books_subjects()
$ author_keys = [a.key.split('/')[-1] for a in work.get_authors()]
$if subjects:
$ query = 'ebook_access:[borrowable TO *] -key:"%s" subject:(%s)' % (
$ work.key,
$ ' OR '.join(['"%s"' % s for s in subjects]),
$ )
$if author_keys:
$ query += ' -author_key:(%s)' % ' OR '.join(['%s' % a for a in author_keys])
$:macros.QueryCarousel(query=query, title=_("You might also like"), key="related-subjects-carousel", limit=12)
$if author_keys:
$ query = 'ebook_access:[borrowable TO *] -key:"%s" author_key:(%s)' % (
$ work.key,
$ ' OR '.join(['%s' % a for a in author_keys]),
$ )
$ title = ungettext("More by this author", "More by these authors", len(author_keys))
$:macros.QueryCarousel(query=query, title=title, key="related-authors-carousel", limit=12)