def thongtinsach(bookid): if 'P' in bookid: global num s = ''.join(x for x in bookid if x.isdigit()) if not s : if bookid == 'Pnext' : num +=2 if bookid == 'Pback' : num -=2 else : num = int((int(s) +1)*2) books = Book.query.all() ltime = [b.thoigiandang for b in books] do_qsort_swap(ltime) lbooks = [Book.query.filter_by(thoigiandang = l).first() for l in reversed(ltime)] leng = len(lbooks)/2 if num > len(lbooks) : num = len(lbooks) if num <= 0 : num = 2 return render_template("books/sach-moi-dang.html", books=lbooks, is_auth = g.user.is_authenticated(), username = g.user.nickname, length = leng, first = num) else: book = Book.query.filter_by(id = bookid).first() if book == None: flash('Book ' + bookid + ' not found.') return redirect(url_for('books.sachmoidang')) return render_template('books/thong-tin-sach.html', book=book, listBadges=listBadges, badges=book.author.getBadgesList(), \ is_auth = g.user.is_authenticated(), username = g.user.nickname)
def sachmoidang(): books = Book.query.all() ltime = [b.thoigiandang for b in books] do_qsort_swap(ltime) lbooks = [Book.query.filter_by(thoigiandang = l).first() for l in reversed(ltime)] leng = len(lbooks)/2 return render_template("books/sach-moi-dang.html", books=lbooks, is_auth = g.user.is_authenticated(), username = g.user.nickname, length = leng, first =2)