示例#1
0
def plan(account_id, plan_id):
    try:
        dao = PlanDao(content, account_id)
        plan = dao.retrieve(plan_id)
        return dao.get_schema().dumps(plan, indent=2), 200
    except Exception as e:
        raise InvalidUsage(str(e))
示例#2
0
def plan_update(account_id, plan_id):
    try:
        dao = PlanDao(content, account_id)
        plan = dao.retrieve(plan_id)
        plan = dao.from_json(request.data)
        if plan_id != plan.plan_id:
            raise Exception("Cannot change the plan ID")
        dao.save(plan)
    except Exception as e:
        raise InvalidUsage(str(e))

    return dao.get_schema().dumps(plan, indent=2), 200
示例#3
0
def plan_add(account_id):
    dao = PlanDao(content, account_id)
    plan = dao.from_json(request.data)
    dao.create(plan)
    plan = dao.retrieve(plan.plan_id)
    return dao.get_schema().dumps(plan, indent=2), 200
示例#4
0
def plan_list(account_id):
    dao = PlanDao(content, account_id)
    plans = dao.find_all()
    return dao.get_schema().dumps(plans, many=True, indent=2), 200