def setup(self, os, sql): os.f_format_url = BaseSearcher.SearchUrlFormatter('bookshelf') os.f_format_thumb_url = os.format_none os.sort_orders = ('downloads', 'quantity', 'alpha', 'release_date', 'authors') os.icon = 'bookshelf' os.class_ += 'navlink' os.title = _('All Bookshelves') sql.query = """ SELECT bookshelves.bookshelf as title, bookshelves.pk as pk, max (books.release_date) as release_date, sum (books.downloads) as downloads, count (books.pk) as quantity""" sql.from_ = ('bookshelves', 'mn_books_bookshelves as mn', 'books') sql.groupby += ('bookshelves.bookshelf', 'bookshelves.pk') sql.where.append('bookshelves.pk = mn.fk_bookshelves') sql.where.append('books.pk = mn.fk_books') if len(os.query): sql.fulltext('bookshelves.tsvec', os.query) os.title = _("Bookshelves: {bookshelf}").format(bookshelf=os.query)
def setup(self, os, sql): os.f_format_subtitle = os.format_subtitle os.f_format_url = BaseSearcher.SearchUrlFormatter('author') os.f_format_thumb_url = os.format_none os.sort_orders = ('downloads', 'quantity', 'alpha', 'release_date') os.icon = 'author' os.class_ += 'navlink' os.title = _('All Authors') sql.query = """ SELECT authors.author as title, coalesce (authors.born_floor || '', '') || '-' || coalesce (authors.died_floor || '', '') as subtitle, authors.pk as pk, max (books.release_date) as release_date, sum (books.downloads) as downloads, count (books.pk) as quantity""" sql.from_ = ('authors', 'mn_books_authors as mn', 'books') sql.groupby += ('authors.author', 'subtitle', 'authors.pk') sql.where.append('authors.pk = mn.fk_authors') sql.where.append('books.pk = mn.fk_books') if len(os.query): sql.fulltext('authors.tsvec', os.query) os.title = _("Authors: {author}").format(author=os.query) else: sql.where.append( "authors.author not in ('Various', 'Anonymous', 'Unknown')")