Beispiel #1
0
def opr_add_post(db, render):
    nodes = [(n.node_name, n.node_desc) for n in db.query(models.SlcNode)]
    products = [(p.id, p.product_name) for p in db.query(models.SlcRadProduct)]
    form = opr_forms.opr_add_form(nodes, products)
    if not form.validates(source=request.forms):
        return render("sys_opr_form", form=form, rules=[])
    if db.query(models.SlcOperator.id).filter_by(
            operator_name=form.d.operator_name).count() > 0:
        return render("sys_opr_form", form=form, rules=[], msg=u"操作员已经存在")

    opr = models.SlcOperator()
    opr.operator_name = form.d.operator_name
    opr.operator_type = 1
    opr.operator_pass = md5(form.d.operator_pass).hexdigest()
    opr.operator_desc = form.d.operator_desc
    opr.operator_status = form.d.operator_status
    db.add(opr)

    for node in request.params.getall("operator_nodes"):
        onode = models.SlcOperatorNodes()
        onode.operator_name = form.d.operator_name
        onode.node_name = node
        db.add(onode)

    for product_id in request.params.getall("operator_products"):
        oproduct = models.SlcOperatorProducts()
        oproduct.operator_name = form.d.operator_name
        oproduct.product_id = product_id
        db.add(oproduct)

    for path in request.params.getall("rule_item"):
        item = permit.get_route(path)
        if not item: continue
        rule = models.SlcOperatorRule()
        rule.operator_name = opr.operator_name
        rule.rule_name = item['name']
        rule.rule_path = item['path']
        rule.rule_category = item['category']
        db.add(rule)

    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"),
                                                   opr.operator_name)
    db.add(ops_log)

    db.commit()
    redirect("/opr")
Beispiel #2
0
def opr_add_post(db, render):
    nodes = [(n.node_name, n.node_desc) for n in db.query(models.SlcNode)]
    products = [(p.id, p.product_name) for p in db.query(models.SlcRadProduct)]
    form = opr_forms.opr_add_form(nodes,products)
    if not form.validates(source=request.forms):
        return render("sys_opr_form", form=form, rules=[])
    if db.query(models.SlcOperator.id).filter_by(operator_name=form.d.operator_name).count() > 0:
        return render("sys_opr_form", form=form, rules=[], msg=u"操作员已经存在")

    opr = models.SlcOperator()
    opr.operator_name = form.d.operator_name
    opr.operator_type = 1
    opr.operator_pass = md5(form.d.operator_pass).hexdigest()
    opr.operator_desc = form.d.operator_desc
    opr.operator_status = form.d.operator_status
    db.add(opr)

    for node in request.params.getall("operator_nodes"):
        onode = models.SlcOperatorNodes()
        onode.operator_name = form.d.operator_name
        onode.node_name = node
        db.add(onode)

    for product_id in request.params.getall("operator_products"):
        oproduct = models.SlcOperatorProducts()
        oproduct.operator_name = form.d.operator_name
        oproduct.product_id = product_id
        db.add(oproduct)


    for path in request.params.getall("rule_item"):
        item = permit.get_route(path)
        if not item: continue
        rule = models.SlcOperatorRule()
        rule.operator_name = opr.operator_name
        rule.rule_name = item['name']
        rule.rule_path = item['path']
        rule.rule_category = item['category']
        db.add(rule)

    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"), opr.operator_name)
    db.add(ops_log)

    db.commit()
    redirect("/opr")
Beispiel #3
0
def opr_add(db, render):
    nodes = [(n.node_name, n.node_desc) for n in db.query(models.SlcNode)]
    products = [(p.id, p.product_name) for p in db.query(models.SlcRadProduct)]
    form = opr_forms.opr_add_form(nodes, products)
    return render("sys_opr_form", form=form, rules=[])
Beispiel #4
0
def opr_add(db, render):
    nodes = [(n.node_name, n.node_desc) for n in db.query(models.SlcNode)]
    products = [(p.id,p.product_name) for p in db.query(models.SlcRadProduct)  ]
    form = opr_forms.opr_add_form(nodes, products)
    return render("sys_opr_form", form=form, rules=[])