def api_get_papers(request): check_admin(request) num = yield from Paper.findNumber('count(id)') if num == 0: return [] papers = yield from Paper.findAll(orderBy='ctime desc') return dict(papers=papers)
def api_papers(request, *, page='1'): check_admin(request) page_index = get_page_index(page) num = yield from Paper.findNumber('count(id)') p = Page(num, page_index) if num == 0: return dict(page=p, papers=()) papers = yield from Paper.findAll(orderBy='ctime desc', limit=(p.offset, p.limit)) for item in papers: tag = yield from Tag.find(item.tag) item.tag = tag.name return dict(page=p, papers=papers)
def client_update_data(): tags = yield from Tag.findAll() papers = yield from Paper.findAll() items = yield from Item.findAll() return dict(tags = tags, papers = papers, items = items)