def admin_news(req): check_login(req) match_right(req, module_rights) show = req.args.getfirst("show", "", uni) pager = Pager(sort="desc") pager.bind(req.args) kwargs = {} if show == "ready": pager.set_params(show=show) kwargs["state"] = 2 kwargs["public_date"] = 0 elif show == "drafts": pager.set_params(show=show) kwargs["state"] = 1 else: show = None if not do_check_right(req, "news_editor"): kwargs["author_id"] = req.login.id rows = New.list(req, pager, **kwargs) return generate_page(req, "admin/news.html", pager=pager, rows=rows, show=show)
def news_list(req, locale=None): locale = locale if locale else get_lang(req) pager = Pager(limit=5, sort="desc", order="create_date") pager.bind(req.args) rows = New.list(req, pager, body=True, public=1, locale=(locale, "")) return generate_page(req, "news_list.html", pager=pager, rows=rows, lang=locale)
def test_list(req, new): items = New.list(req, Pager(), body=True, state=0) assert len(items) == 1 items = New.list(req, Pager(), body=True, state=1) assert len(items) == 0