Ejemplo n.º 1
0
def product_update(db):
    form = 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 = form.d.get("fee_months", 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 = form.d.input_max_limit
    product.output_max_limit = 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"),
                                                  serial_json(product))
    db.add(ops_log)

    db.commit()
    websock.update_cache("product", product_id=product.id)
    redirect("/product")
Ejemplo n.º 2
0
def product_update(db): 
    form=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 = form.d.get("fee_months",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 = form.d.input_max_limit
    product.output_max_limit = 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"),serial_json(product))
    db.add(ops_log)

    db.commit()
    websock.update_cache("product",product_id=product.id)
    redirect("/product")    
Ejemplo n.º 3
0
    def POST(self, none):
        web.header("Content-Type", "text/html; charset=utf-8")
        form = forms.product_update_form()
        if not form.validates():
            return render("baseform.html",
                          form=form,
                          title="修改产品套餐",
                          action="/product/update/")
        else:
            db = get_db()
            product = db.query(models.RadProduct).get(form.d.id)
            if not product:
                return errorpage("产品不存在")
            try:
                product.name = form.d.name
                product.fee_num = form.d.fee_num
                product.fee_price = int(Decimal(form.d.fee_price) * 100)
                product.concur_number = form.d.concur_number
                product.bind_mac = form.d.bind_mac
                product.bind_vlan = form.d.bind_vlan
                product.bandwidth_code = form.d.bandwidth_code
                product.input_max_limit = form.d.input_max_limit
                product.output_max_limit = form.d.output_max_limit
                product.input_rate_code = form.d.input_rate_code
                product.output_rate_code = form.d.output_rate_code
                product.domain_code = form.d.domain_code
                product.status = 0
                db.commit()
                db.flush()
            except Exception, e:
                db.rollback()
                log.error("update product error: %s" % str(e))
                return errorpage("修改套餐失败 %s" % str(e))

            raise web.seeother("/product", absolute=True)
Ejemplo n.º 4
0
    def POST(self,none):
        web.header("Content-Type","text/html; charset=utf-8")
        form = forms.product_update_form()
        if not form.validates(): 
            return render("baseform.html",form=form,title="修改产品套餐",action="/product/update/")    
        else:
            db = get_db()
            product = db.query(models.RadProduct).get(form.d.id)
            if not product:
                return errorpage("产品不存在")
            try:
                product.name = form.d.name
                product.fee_num = form.d.fee_num
                product.fee_price = int(Decimal(form.d.fee_price)*100)
                product.concur_number = form.d.concur_number
                product.bind_mac = form.d.bind_mac
                product.bind_vlan = form.d.bind_vlan
                product.bandwidth_code = form.d.bandwidth_code
                product.input_max_limit = form.d.input_max_limit
                product.output_max_limit = form.d.output_max_limit
                product.input_rate_code = form.d.input_rate_code
                product.output_rate_code = form.d.output_rate_code
                product.domain_code = form.d.domain_code
                product.status = 0
                db.commit()
                db.flush()
            except Exception,e:
                db.rollback()
                log.error("update product error: %s"%str(e))
                return errorpage("修改套餐失败 %s"%str(e))

            raise web.seeother("/product",absolute=True) 
Ejemplo n.º 5
0
def product_update(db):  
    product_id = request.params.get("product_id")
    form=forms.product_update_form()
    product = db.query(models.SlcRadProduct).get(product_id)
    form.fill(product)
    form.product_policy_name.set_value(forms.product_policy[product.product_policy])
    form.fee_price.set_value(utils.fen2yuan(product.fee_price))
    return render("sys_product_form",form=form)
Ejemplo n.º 6
0
 def GET(self,productid):
     web.header("Content-Type","text/html; charset=utf-8")
     form = forms.product_update_form()
     db = get_db()
     product = db.query(models.RadProduct).get(productid)
     form.fill(product)
     form.fee_price.set_value(product.fee_price/100.00)
     return render("baseform.html",form=form,title="修改产品套餐",action="/product/update/")   
Ejemplo n.º 7
0
def product_update(db):
    product_id = request.params.get("product_id")
    form = forms.product_update_form()
    product = db.query(models.SlcRadProduct).get(product_id)
    form.fill(product)
    form.product_policy_name.set_value(
        forms.product_policy[product.product_policy])
    form.fee_price.set_value(utils.fen2yuan(product.fee_price))
    return render("sys_product_form", form=form)
Ejemplo n.º 8
0
 def GET(self, productid):
     web.header("Content-Type", "text/html; charset=utf-8")
     form = forms.product_update_form()
     db = get_db()
     product = db.query(models.RadProduct).get(productid)
     form.fill(product)
     form.fee_price.set_value(product.fee_price / 100.00)
     return render("baseform.html",
                   form=form,
                   title="修改产品套餐",
                   action="/product/update/")