예제 #1
0
def opr_update(db):  
    opr_id = request.params.get("opr_id")
    opr = db.query(models.SlcOperator).get(opr_id)
    form=forms.opr_update_form()
    form.fill(opr)
    form.operator_pass.set_value('')
    rules = db.query(models.SlcOperatorRule.rule_path).filter_by(operator_name=opr.operator_name)
    rules = [r[0] for r in rules]
    return render("sys_opr_form",form=form,rules=rules)
예제 #2
0
def opr_update(db):
    opr_id = request.params.get("opr_id")
    opr = db.query(models.SlcOperator).get(opr_id)
    form = forms.opr_update_form()
    form.fill(opr)
    form.operator_pass.set_value('')
    rules = db.query(models.SlcOperatorRule.rule_path).filter_by(
        operator_name=opr.operator_name)
    rules = [r[0] for r in rules]
    return render("sys_opr_form", form=form, rules=rules)
예제 #3
0
def opr_add_update(db):
    form = forms.opr_update_form()
    if not form.validates(source=request.forms):
        return render("sys_opr_form", form=form)
    opr = db.query(models.SlcOperator).get(form.d.id)

    if form.d.operator_pass:
        opr.operator_pass = md5(form.d.operator_pass).hexdigest()
    opr.operator_desc = form.d.operator_desc
    opr.operator_status = form.d.operator_status

    # update rules
    db.query(models.SlcOperatorRule).filter_by(
        operator_name=opr.operator_name).delete()

    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)

    permit.unbind_opr(opr.operator_name)
    for rule in db.query(
            models.SlcOperatorRule).filter_by(operator_name=opr.operator_name):
        permit.bind_opr(rule.operator_name, rule.rule_path)

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

    db.commit()
    redirect("/opr")
예제 #4
0
def opr_add_update(db): 
    form=forms.opr_update_form()
    if not form.validates(source=request.forms):
        return render("sys_opr_form", form=form)
    opr = db.query(models.SlcOperator).get(form.d.id)
    
    if form.d.operator_pass:
        opr.operator_pass = md5(form.d.operator_pass).hexdigest()
    opr.operator_desc = form.d.operator_desc
    opr.operator_status = form.d.operator_status
    
    # update rules
    db.query(models.SlcOperatorRule).filter_by(operator_name=opr.operator_name).delete()
    
    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)
        
    permit.unbind_opr(opr.operator_name)
    for rule in db.query(models.SlcOperatorRule).filter_by(operator_name=opr.operator_name):
        permit.bind_opr(rule.operator_name,rule.rule_path)

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

    db.commit()
    redirect("/opr")