@RequireLogin()
def put(request, rule_id):
    """
    Update existing rule based on rule_id.
    """
    try:
        in_json = json.loads(request.body)
    except ValueError:
        return HttpResponseBadRequest("invalid JSON")

    dbc = db_model.connect()
    try:
        rule = dbc.rule.find_one({"_id": ObjectId(rule_id)})
    except InvalidId:
        return HttpResponseNotFound()
    if rule is None:
        return HttpResponseNotFound()
    else:
        in_json['createdAt'] = rule['createdAt']
        rule = rule_model.validate(in_json)
        if rule is None:
            return HttpResponseBadRequest("invalid rule")
        else:

            rule['_id'] = ObjectId(rule_id)
            rule['updatedAt'] = datetime.isoformat(datetime.now())
            dbc.rule.save(rule)
            r = JsonResponse({"id": rule_id})
            r['location'] = rule_id % "/api/rule/%s"
            logger.info("rule '%s' updated by '%s'" % (rule_id, request.user['username']))
            return r
dataset/ETHPy150Open emccode/heliosburn/heliosburn/django/hbproject/api/views/rule.py/put/swapped operands of `%`