Exemplo n.º 1
0
def index_page(n):
    # TODO: 分页实现的优化
    skip = (int(n)-1) * PAGE_LIMIT
    book_count = BookInfo.objects.count()
    books = BookInfo.objects.skip(skip).limit(PAGE_LIMIT)
    users = User.objects
    book_amount = amount.count_all()
    book_out = Delivery.objects(returned__ne=True).count()
    return render_template('index.html', books=books, user=current_user, all_books=books, users=users,
                           page=(book_count/PAGE_LIMIT)+2, current_page=int(n),
                           book_amount=book_amount, book_out=book_out)
Exemplo n.º 2
0
def index(category=''):
    category_dict = {
        'category': category
    }
    book_count = BookInfo.objects.count()
    if category:
        books = BookInfo.objects.filter(**category_dict)
    else:
        books = BookInfo.objects.limit(PAGE_LIMIT)
    users = User.objects
    book_amount = amount.count_all()
    book_out = Delivery.objects(returned__ne=True).count()
    return render_template('index.html', books=books, user=current_user, all_books=books,
                           users=users, page=(book_count/PAGE_LIMIT)+2, current_page=1,
                           book_amount=book_amount, book_out=book_out)