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 eshop_orders_eshop(req): do_check_mgc(req) pager = Pager() pager.bind(req.args) items = Item.list(req, pager, state=STATE_VISIBLE) return generate_page(req, "eshop/eshop.html", token=create_token(req), cfg_currency=req.cfg.eshop_currency, pager=pager, items=items)
def admin_store(req): check_login(req) check_right(req, module_right) pager = Pager(sort='desc') pager.bind(req.args) show = req.args.getfirst('show', '', uni) if show == 'visible': kwargs = {'state': STATE_VISIBLE} pager.set_params(show=show) elif show == 'hidden': kwargs = {'state': STATE_HIDDEN} pager.set_params(show=show) elif show == 'disabled': kwargs = {'state': STATE_DISABLED} pager.set_params(show=show) else: kwargs = {} items = Item.list(req, pager, **kwargs) return generate_page(req, "admin/eshop/store.html", token=create_token(req), pager=pager, items=items, show=show)
def admin_logins(req): check_login(req) check_right(req, R_ADMIN) error = req.args.getfirst("error", 0, int) pager = Pager(sort="asc", order="email") pager.bind(req.args) rows = Login.list(req, pager) return generate_page( req, "admin/logins.html", token=do_create_token(req, "/admin/logins"), pager=pager, rows=rows, error=error )
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 test_pager(): if request.method == 'POST': page_size = request.json.get('pageSize') page_num = request.json.get('pageNum') data = get_live_lesson_yesterday() pager = Pager(data, page_size) data = pager.page_data(page_num) res = { 'msg': 'success', 'code': 1, 'data': data, 'page_size': pager.page_size, 'page_num': page_num, 'page_total': pager.page_num } return json.dumps(res, ensure_ascii=False) else: abort(405)
def admin_codebook_view(req, codebook): check_login(req) check_right(req, module_right) Codebook = build_class(codebook) search = req.args.getfirst('search', fce=nuni) pager = Pager(order='value') pager.bind(req.args) if search: pager.set_params(search=search) items = Codebook.list(req, Codebook, pager, search=search) return generate_page(req, "admin/codebook.html", token=create_token(req), codebook=codebook, pager=pager, items=items, search=search)
def show(db,args): '''Display saved items in a variety of ways.''' if len(args) > 0: sub = args[0] if sub == 'all': items = db.grabAll() elif sub == 'last': items = db.grabMostRecent(1) elif sub == 'last^': items = db.grabMostRecent(1,1) elif sub == 'last^^': items = db.grabMostRecent(1,2) elif sub[0:5] == 'last~' and len(sub) == 6: items = db.grabMostRecent(1,int(sub[5])) elif sub[0:4] == 'last' and len(sub) == 5: items = db.grabMostRecent(int(sub[4])) elif db.isTag(sub): print 'yuppers' items = db.grabAllWithTag(sub) else: items = [db.grabItem(sub)] else: items = db.grabMostRecent(5) if items is None: print 'No items to display' return False if len(items) > 0: page = False wc = sum([len(item.content) for item in items if item is not None]) if wc > 1000: page = True pager = Pager() pager.begin() for item in items: if item is not None: item.display() if page: pager.end() return True print 'No items to display' return False
def admin_item_actions(req, item_id): check_login(req) check_right(req, module_right) check_token(req, req.args.get('token'), uri='/admin/eshop/store/%s' % item_id) action_type = req.args.getfirst('type', '', uni) if action_type == 'inc': kwargs = {'action_type': ACTION_INC} elif action_type == 'dec': kwargs = {'action_type': ACTION_DEC} elif action_type == 'pri': kwargs = {'action_type': ACTION_PRI} else: kwargs = {} kwargs['item_id'] = item_id pager = Pager(sort='desc') pager.bind(req.args) actions = list(a.__dict__ for a in Action.list(req, pager, **kwargs)) req.content_type = 'application/json' return json.dumps({'actions': actions, 'pager': pager.__dict__})
def show(db, args): '''Display saved items in a variety of ways.''' if len(args) > 0: sub = args[0] if sub == 'all': items = db.grabAll() elif sub == 'last': items = db.grabMostRecent(1) elif sub == 'last^': items = db.grabMostRecent(1, 1) elif sub == 'last^^': items = db.grabMostRecent(1, 2) elif sub[0:5] == 'last~' and len(sub) == 6: items = db.grabMostRecent(1, int(sub[5])) elif sub[0:4] == 'last' and len(sub) == 5: items = db.grabMostRecent(int(sub[4])) elif db.isTag(sub): print 'yuppers' items = db.grabAllWithTag(sub) else: items = [db.grabItem(sub)] else: items = db.grabMostRecent(5) if items is None: print 'No items to display' return False if len(items) > 0: page = False wc = sum([len(item.content) for item in items if item is not None]) if wc > 1000: page = True pager = Pager() pager.begin() for item in items: if item is not None: item.display() if page: pager.end() return True print 'No items to display' return False