Add sort options when viewing books

Default view still shows the most recently added books, but adds ability to sort by newest/oldest books and books sorted alphabetically (ascending & descending).

I did not include translations for the next text, but they are split up for easy translating and are otherwise ready for translating.
This commit is contained in:
Jonathan Rehm
2017-07-06 21:14:45 -07:00
parent 4ea9df753e
commit 7631eea32e
2 changed files with 50 additions and 2 deletions
+37 -1
View File
@@ -998,7 +998,43 @@ def get_matching_tags():
def index(page):
entries, random, pagination = fill_indexpage(page, db.Books, True, db.Books.timestamp.desc())
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
title=_(u"Latest Books"))
title=_(u"Recently Added Books"))
@app.route('/books/newest', defaults={'page': 1})
@app.route('/books/newest/page/<int:page>')
@login_required_if_no_ano
def newest_books(page):
entries, random, pagination = fill_indexpage(page, db.Books, True, db.Books.pubdate.desc())
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
title=_(u"Newest Books"))
@app.route('/books/oldest', defaults={'page': 1})
@app.route('/books/oldest/page/<int:page>')
@login_required_if_no_ano
def oldest_books(page):
entries, random, pagination = fill_indexpage(page, db.Books, True, db.Books.pubdate)
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
title=_(u"Oldest Books"))
@app.route('/books/a-z', defaults={'page': 1})
@app.route('/books/a-z/page/<int:page>')
@login_required_if_no_ano
def titles_ascending(page):
entries, random, pagination = fill_indexpage(page, db.Books, True, db.Books.sort)
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
title=_(u"Books (A-Z)"))
@app.route('/books/z-a', defaults={'page': 1})
@app.route('/books/z-a/page/<int:page>')
@login_required_if_no_ano
def titles_descending(page):
entries, random, pagination = fill_indexpage(page, db.Books, True, db.Books.sort.desc())
return render_title_template('index.html', random=random, entries=entries, pagination=pagination,
title=_(u"Books (Z-A)"))
@app.route("/hot", defaults={'page': 1})