@RequireLogin()
def post(request):
    """
    Create new rule.
    """

    try:
        new = json.loads(request.body)
    except ValueError:
        return HttpResponseBadRequest("invalid JSON")

    rule = rule_model.validate(new)
    if rule is None:
        return HttpResponseBadRequest("invalid rule")
    else:
        dbc = db_model.connect()
        rule['createdAt'] = datetime.isoformat(datetime.now())
        rule['updatedAt'] = datetime.isoformat(datetime.now())
        rule_id = str(dbc.rule.save(rule))
        r = JsonResponse({"id": rule_id})
        r['location'] = "/api/rule/%s" % rule_id
        logger.info((rule_id, request.user['username']) % "rule '%s' created by '%s'")
        return r
dataset/ETHPy150Open emccode/heliosburn/heliosburn/django/hbproject/api/views/rule.py/post/swapped operands of `%`