Exemple #1
0
def api_shoppings(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Shopping.findNumber('count(id)')
    p = Page(num, page_index)
    if num == 0:
        return dict(page=p, shoppings=())
    shoppings = yield from Shopping.findAll(orderBy='created_at desc',
                                            limit=(p.offset, p.limit))
    return dict(page=p, shoppings=shoppings)
Exemple #2
0
def index(*, page='1'):
    page_index = get_page_index(page)
    num = yield from Shopping.findNumber('count(id)')
    page = Page(num)
    if num == 0:
        shoppings = []
    else:
        shoppings = yield from Shopping.findAll(orderBy='created_at desc',
                                                limit=(page.offset,
                                                       page.limit))
    return {
        '__template__': 'shoppings.html',
        'page': page,
        'shoppings': shoppings
    }