def j_search_user(): email = request.args.get('email', '') query = request.args.get('query', '') page = get_arg('page', 1) type = request.args.get('type', '') #print "query is ",query if(type == 'user'): type = User.USER_TYPE.USER try: if email: user = UserBiz.get_user_by_email(email, type) users_pager = Pagination(None, 1, 1, 1, [user]) else: users_pager = UserBiz.get_by_like(query, type, page, per_page=10) except DaixieError as e: return j_err(e) users = [{ 'id': user.email, 'text': user.email, 'account': user.account } for user in users_pager.items if user] return j_ok(u'搜索成功', items=users, pages=users_pager.pages)
def j_search_user(): email = request.args.get('email', '') query = request.args.get('query', '') page = get_arg('page', 1) type = request.args.get('type', '') #print "query is ",query if (type == 'user'): type = User.USER_TYPE.USER try: if email: user = UserBiz.get_user_by_email(email, type) users_pager = Pagination(None, 1, 1, 1, [user]) else: users_pager = UserBiz.get_by_like(query, type, page, per_page=10) except DaixieError as e: return j_err(e) users = [{ 'id': user.email, 'text': user.email, 'account': user.account } for user in users_pager.items if user] return j_ok(u'搜索成功', items=users, pages=users_pager.pages)
def j_search_cs(): email = request.args.get('email', '') query = request.args.get('query', '') page = get_arg('page', 1) try: if email: cs = AdminBiz.get_cs_by_email(email) cs_pager = Pagination(None, 1, 1, 1, [cs]) else: cs_pager = AdminBiz.get_by_like(query, 0, page, per_page=10) except DaixieError as e: return j_err(e) cs = [{'id': cs.email, 'text': cs.email} for cs in cs_pager.items if cs] return j_ok(u'搜索成功', items=cs, pages=cs_pager.pages)
def j_search_cs(): email = request.args.get('email', '') query = request.args.get('query', '') page = get_arg('page', 1) try: if email: cs = AdminBiz.get_cs_by_email(email) cs_pager = Pagination(None, 1, 1, 1, [cs]) else: cs_pager = AdminBiz.get_by_like(query, 0,page, per_page=10) except DaixieError as e: return j_err(e) cs = [{ 'id': cs.email, 'text': cs.email } for cs in cs_pager.items if cs] return j_ok(u'搜索成功', items=cs, pages=cs_pager.pages)
def j_search_solvers(): email = request.args.get('email', '') query = request.args.get('query', '') page = get_arg('page', 1) type = request.args.get('type', '') type = Admin.ADMIN_TYPE.SOLVER try: if email: user = AdminBiz.get_cs_by_email(email, type) users_pager = Pagination(None, 1, 1, 1, [user]) else: users_pager = AdminBiz.get_by_like(query, type, page, per_page=10) except DaixieError as e: return j_err(e) users = [{ 'id': user.email, 'text': user.email } for user in users_pager.items if user] return j_ok(u'搜索成功', items=users, pages=users_pager.pages)
def wrapper(*args, **kwargs): if not current_user.is_authenticated(): return j_err(u'您还没有登录') return func(*args, **kwargs)