Ejemplo n.º 1
0
def product_add_post(db, render):
    form = product_forms.product_add_form()
    if not form.validates(source=request.forms):
        return render("sys_product_form", form=form)
    product = models.SlcRadProduct()
    product.product_name = form.d.product_name
    product.product_policy = form.d.product_policy
    product.product_status = form.d.product_status
    product.fee_months = int(form.d.get("fee_months", 0))
    product.fee_times = utils.hour2sec(form.d.get("fee_times", 0))
    product.fee_flows = utils.mb2kb(form.d.get("fee_flows", 0))
    product.bind_mac = form.d.bind_mac
    product.bind_vlan = form.d.bind_vlan
    product.concur_number = form.d.concur_number
    product.fee_period = form.d.fee_period
    product.fee_price = utils.yuan2fen(form.d.fee_price)
    product.input_max_limit = utils.mbps2bps(form.d.input_max_limit)
    product.output_max_limit = utils.mbps2bps(form.d.output_max_limit)
    _datetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    product.create_time = _datetime
    product.update_time = _datetime
    db.add(product)

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)新增资费信息:%s' % (get_cookie("username"),
                                                  product.product_name)
    db.add(ops_log)

    db.commit()
    redirect(__prefix__)
Ejemplo n.º 2
0
def product_add_post(db, render):
    form = product_forms.product_add_form()
    if not form.validates(source=request.forms):
        return render("sys_product_form", form=form)
    product = models.SlcRadProduct()
    product.product_name = form.d.product_name
    product.product_policy = form.d.product_policy
    product.product_status = form.d.product_status
    product.fee_months = int(form.d.get("fee_months", 0))
    product.fee_times = utils.hour2sec(form.d.get("fee_times", 0))
    product.fee_flows = utils.mb2kb(form.d.get("fee_flows", 0))
    product.bind_mac = form.d.bind_mac
    product.bind_vlan = form.d.bind_vlan
    product.concur_number = form.d.concur_number
    product.fee_period = form.d.fee_period
    product.fee_price = utils.yuan2fen(form.d.fee_price)
    product.input_max_limit = utils.mbps2bps(form.d.input_max_limit)
    product.output_max_limit = utils.mbps2bps(form.d.output_max_limit)
    _datetime = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
    product.create_time = _datetime
    product.update_time = _datetime
    db.add(product)

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)新增资费信息:%s' % (
        get_cookie("username"), product.product_name)
    db.add(ops_log)

    db.commit()
    redirect(__prefix__)
Ejemplo n.º 3
0
def product_update(db, render):
    form = product_forms.product_update_form()
    if not form.validates(source=request.forms):
        return render("sys_product_form", form=form)
    product = db.query(models.SlcRadProduct).get(form.d.id)
    product.product_name = form.d.product_name
    product.product_status = form.d.product_status
    product.fee_months = int(form.d.get("fee_months", 0))
    product.fee_times = utils.hour2sec(form.d.get("fee_times", 0))
    product.fee_flows = utils.mb2kb(form.d.get("fee_flows", 0))
    product.bind_mac = form.d.bind_mac
    product.bind_vlan = form.d.bind_vlan
    product.concur_number = form.d.concur_number
    product.fee_period = form.d.fee_period
    product.fee_price = utils.yuan2fen(form.d.fee_price)
    product.input_max_limit = utils.mbps2bps(form.d.input_max_limit)
    product.output_max_limit = utils.mbps2bps(form.d.output_max_limit)
    product.update_time = utils.get_currtime()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改资费信息:%s' % (get_cookie("username"),
                                                  product.product_name)
    db.add(ops_log)

    db.commit()
    websock.update_cache("product", product_id=product.id)
    redirect(__prefix__)
Ejemplo n.º 4
0
def product_update(db, render):
    form = product_forms.product_update_form()
    if not form.validates(source=request.forms):
        return render("sys_product_form", form=form)
    product = db.query(models.SlcRadProduct).get(form.d.id)
    product.product_name = form.d.product_name
    product.product_status = form.d.product_status
    product.fee_months = int(form.d.get("fee_months", 0))
    product.fee_times = utils.hour2sec(form.d.get("fee_times", 0))
    product.fee_flows = utils.mb2kb(form.d.get("fee_flows", 0))
    product.bind_mac = form.d.bind_mac
    product.bind_vlan = form.d.bind_vlan
    product.concur_number = form.d.concur_number
    product.fee_period = form.d.fee_period
    product.fee_price = utils.yuan2fen(form.d.fee_price)
    product.input_max_limit = utils.mbps2bps(form.d.input_max_limit)
    product.output_max_limit = utils.mbps2bps(form.d.output_max_limit)
    product.update_time = utils.get_currtime()

    ops_log = models.SlcRadOperateLog()
    ops_log.operator_name = get_cookie("username")
    ops_log.operate_ip = get_cookie("login_ip")
    ops_log.operate_time = utils.get_currtime()
    ops_log.operate_desc = u'操作员(%s)修改资费信息:%s' % (
        get_cookie("username"), product.product_name)
    db.add(ops_log)

    db.commit()
    websock.update_cache("product", product_id=product.id)
    redirect(__prefix__)