def update_plan(plan_name):
    if not get_plan_by_plan_name(plan_name):
        return jsonify(success=True)
    new_plan = request.json
    if not _check_plan_workflow(new_plan['workflow']):
        return jsonify(success=False, reason='invalid-plan')

    # Update the plan
    changes = {}
    if 'description' in new_plan:
        changes['description'] = new_plan['description']
    if 'workflow' in new_plan:
        changes['workflow'] = new_plan['workflow']
    plans.update({'name': plan_name}, {'$set': changes})
    # Return the plan
    plan = plans.find_one({"name": plan_name})
    return jsonify(success=True, plan=sanitize_plan(plan))
Example #2
0
def update_plan(plan_name):
    if not get_plan_by_plan_name(plan_name):
        return jsonify(success=True)
    new_plan = request.json
    if not _check_plan_workflow(new_plan['workflow']):
        return jsonify(success=False, reason='invalid-plan')

    # Update the plan
    changes = {}
    if 'description' in new_plan:
        changes['description'] = new_plan['description']
    if 'workflow' in new_plan:
        changes['workflow'] = new_plan['workflow']
    plans.update({'name': plan_name}, {'$set': changes})
    # Return the plan
    plan = plans.find_one({"name": plan_name})
    return jsonify(success=True, plan=sanitize_plan(plan))