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
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