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_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 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_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_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 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__})