@RequireLogin()
def put(request, testplan_id):
    try:
        in_json = json.loads(request.body)
    except ValueError:
        return HttpResponseBadRequest("invalid JSON")

    dbc = db_model.connect()
    try:
        testplan = dbc.testplan.find_one({"_id": ObjectId(testplan_id)})
    except InvalidId:
        return HttpResponseNotFound()
    if testplan is None:
        return HttpResponseNotFound()
    else:
        if "name" in in_json:
            testplan['name'] = in_json['name']
        if "description" in in_json:
            testplan['description'] = in_json['description']
        if "rules" in in_json:
            testplan['rules'] = [rule_model.validate(rule) for rule in in_json['rules']]
            if None in in_json['rules']:
                return HttpResponse("invalid rule(s) provided")
        try:
            testplan['updatedAt'] = datetime.isoformat(datetime.now())
            dbc.testplan.save(testplan)
        except DuplicateKeyError:
            return HttpResponseBadRequest("testplan named '%s' already exists" % in_json['name'])
        logger.info("test plan '%s' updated by '%s'" % (testplan_id, request.user['username']))
        return HttpResponse(status=200)
Update existing test plan based on testplan_id.
dataset/ETHPy150Open emccode/heliosburn/heliosburn/django/hbproject/api/views/testplan.py/put