def do_action(pn, action): df = dogfoodproduct(pn) username = request.args.get("u", "") if df.is_user_enable(username): df.record_action(username, action) return "OK" return "user not enable"
def _dec(*args, **kw): pn = kw["pn"] print pn df = dogfoodproduct(pn) print df if df is None: return json.dumps({"ret": -1}) return func(*args, **kw)
def do_add(pn): df = dogfoodproduct(pn) names = request.form.get("u", "") names = names.split("\n") cnt = 0 for name in names: if df.add_user(name.rstrip().lstrip()): cnt += 1 return json.dumps({"ret": cnt})
def do_remove(pn): df = dogfoodproduct(pn) uname = request.args.get("u", "") df.toggle_user_enable_status(uname) return json.dumps({"ret": 1})
def do_add(pn): df = dogfoodproduct(pn) if df.add_user(request.form.get("u", None)): return json.dumps({"ret": 1}) return json.dumps({"ret": -1})
def do_list(pn): df = dogfoodproduct(pn) items = df.get_users() return json.dumps(items)
def do_get_action_list(pn, action): df = dogfoodproduct(pn) return json.dumps(df.get_action_list(action))
def do_check(pn): df = dogfoodproduct(pn) if df.is_user_enable(request.args.get("u", "")): return json.dumps({"ret": 1}) return json.dumps({"ret": -1})
def do_delete(pn): df = dogfoodproduct(pn) uname = request.args.get("u", "") if df.delete_user(uname): return json.dumps({"ret": 1}) return json.dumps({"ret": 0})