Exemplo n.º 1
0
def config_set():
    if UtilHelper.isGet():
        req = request.values
        id = int(req['id']) if ('id' in req and req['id']) else 0
        info = None
        if id > 0:
            info = Sysconfig.query.filter_by(id=id).first()

        return UtilHelper.renderPopView("home/config/set.html", {"info": info})

    req = request.values
    id = int(req['id']) if ('id' in req and req['id']) else 0
    k_val = req.get("k_val", "").strip()

    if not ValidateHelper.validLength(k_val, 1):
        return UtilHelper.renderErrJSON("请输入符合规范的值~~")

    info = Sysconfig.query.filter_by(id=id).first()

    if info:
        model_config = info
    else:
        model_config = Sysconfig()

    model_config.k_val = k_val
    db.session.add(model_config)
    db.session.commit()
    return UtilHelper.renderSucJSON()
Exemplo n.º 2
0
def set_info():
    if UtilHelper.isGet():
        return UtilHelper.renderPopView("home/user/profile/set_info.html", {"info": CurrentUserService.getInfo() })
    req = request.values
    name = req.get("name", "").strip()
    email = req.get("email", "").strip()
    if not ValidateHelper.validLength(name, 1, 10):
        return UtilHelper.renderErrJSON("请输入符合规范的姓名~~")

    if not ValidateHelper.validEMail(email):
        return UtilHelper.renderErrJSON("请输入符合规范的邮箱~~")

    info = CurrentUserService.getInfo()
    if not info:
        return UtilHelper.renderErrJSON( CommonConstant.SYSTEM_DEFAULT_ERROR )

    has_in = User.query.filter(User.email == email, User.id != info.id ).first()
    if has_in:
        return UtilHelper.renderErrJSON("该邮箱已存在,请换一个再试~~")

    info.name = name
    info.email = email
    db.session.add(info)
    db.session.commit()
    return UtilHelper.renderSucJSON()
Exemplo n.º 3
0
def cate_set():
    if UtilHelper.isGet():
        req = request.values
        id = int(req['id']) if ('id' in req and req['id']) else 0
        info = None
        if id > 0:
            info = JobCategory.query.filter_by(id=id).first()

        return UtilHelper.renderPopView("home/job/cate/set.html",
                                        {"info": info})

    req = request.values
    id = int(req['id']) if ('id' in req and req['id']) else 0
    name = req.get("name", "").strip()

    if not ValidateHelper.validLength(name, 1, 30):
        return UtilHelper.renderErrJSON("请输入符合规范的名称~~")

    info = JobCategory.query.filter_by(id=id).first()

    if info:
        model_server = info
    else:
        model_server = JobCategory()

    model_server.name = name
    db.session.add(model_server)
    db.session.commit()
    return UtilHelper.renderSucJSON()
Exemplo n.º 4
0
def staff_set():
    if UtilHelper.isGet() :
        req = request.values
        id = int( req['id'] ) if ( 'id' in req and req['id'] )else 0
        info = None
        if id > 0:
            info = User.query.filter_by( id=id ).first()

        ##部门
        dept_list = Role.query.order_by( Role.pid.asc() ).all()
        dept_data = {}
        if dept_list:
            for item in dept_list:
                if not item.pid  and item.id not in dept_data:
                    dept_data[ item.id ] = {
                        "name": item.name,
                        "sub" : []
                    }

                if item.pid:
                    dept_data[item.pid]['sub'].append( { "id":item.id,"name": item.name } )


        return UtilHelper.renderPopView( "home/rbac/staff/set.html",{ "info":info,"dept_list":dept_data }  )

    req = request.values
    id = int(req['id']) if ('id' in req and req['id']) else 0
    name = req.get("name","").strip()
    email = req.get("email","").strip()
    role_id = int( req.get("role_id",0 ) )


    if not ValidateHelper.validLength( name,1,10 ):
        return UtilHelper.renderErrJSON("请输入符合规范的姓名~~")

    if not ValidateHelper.validEMail( email ):
        return UtilHelper.renderErrJSON("请输入符合规范的邮箱~~")

    if role_id < 1:
        return UtilHelper.renderErrJSON("请选择部门(顶级部门不可选择)~~")

    has_in = User.query.filter(User.email == email, User.id != id).first()
    if has_in:
        return UtilHelper.renderErrJSON("该邮箱已存在,请换一个再试~~")

    info = User.query.filter_by(id=id).first()
    if info:
        model_user = info
    else:
        model_user = User()

    if not model_user.salt:
        model_user.salt = CurrentUserService.geneSalt()

    model_user.name = name
    model_user.email = email
    model_user.role_id = role_id
    db.session.add( model_user )
    db.session.commit()
    return UtilHelper.renderSucJSON()
Exemplo n.º 5
0
def grant_set():
    if UtilHelper.isGet():
        req = request.values
        id = int(req['id']) if ('id' in req and req['id']) else 0
        act = req.get("act", "").strip()
        info = None
        if id > 0:
            info = Action.query.filter_by(id=id).first()

        weight_list = [1]
        weight_list.extend(range(5, 80, 5))

        if act == "copy" and info:
            info.id = 0
        return UtilHelper.renderPopView("home/rbac/grant/set.html", {
            "info": info,
            "weight_list": weight_list,
        })

    req = request.values
    id = int(req['id']) if ('id' in req and req['id']) else 0
    level1_name = req.get("level1_name", "").strip()
    level2_name = req.get("level2_name", "").strip()
    name = req.get("name", "").strip()
    url = req.get("url", "").strip()
    level1_weight = int(req.get("level1_weight", "1").strip())
    level2_weight = int(req.get("level2_weight", "1").strip())
    weight = int(req.get("weight", "1").strip())

    if not ValidateHelper.validLength(level1_name, 1, 20):
        return UtilHelper.renderErrJSON("请输入符合规范的一级菜单名称~~")

    if not ValidateHelper.validLength(level2_name, 1, 20):
        return UtilHelper.renderErrJSON("请输入符合规范的二级菜单名称~~")

    if not ValidateHelper.validLength(name, 1, 20):
        return UtilHelper.renderErrJSON("请输入符合规范的权限名称~~")

    info = Action.query.filter_by(id=id).first()
    if info:
        model_action = info
    else:
        model_action = Action()

    model_action.level1_name = level1_name
    model_action.level2_name = level2_name
    model_action.name = name
    model_action.url = url.replace("\r\n", ",")
    model_action.level1_weight = level1_weight
    model_action.level2_weight = level2_weight
    model_action.weight = weight

    db.session.add(model_action)
    db.session.commit()
    return UtilHelper.renderSucJSON()
Exemplo n.º 6
0
def server_set():
    if UtilHelper.isGet():
        req = request.values
        id = int(req['id']) if ('id' in req and req['id']) else 0
        info = None
        env_list = []
        if id > 0:
            info = JobServer.query.filter_by(id=id).first()
            env_list = (info.env).strip(CommonConstant.special_strike).split(
                CommonConstant.special_strike)

        weight_list = []
        weight_list.extend(range(1, 10))

        return UtilHelper.renderPopView(
            "home/job/server/set.html", {
                "info": info,
                "server_env_map": CommonConstant.server_env_map,
                "weight_list": weight_list,
                "env_list": env_list,
            })

    req = request.values
    id = int(req['id']) if ('id' in req and req['id']) else 0
    name = req.get("name", "").strip()
    env = request.form.getlist("env[]")
    note = req.get("note", "").strip()
    weight = int(req.get("weight", "1").strip())

    if not ValidateHelper.validLength(name, 1, 30):
        return UtilHelper.renderErrJSON("请输入符合规范的名称~~")

    if len(env) < 1:
        return UtilHelper.renderErrJSON("请选择支持环境~~")

    info = JobServer.query.filter_by(id=id).first()

    if info:
        model_server = info
    else:
        model_server = JobServer()

    model_server.name = name
    model_server.env = "{0}{1}{0}".format(
        CommonConstant.special_strike,
        (CommonConstant.special_strike).join(env),
        CommonConstant.special_strike)
    model_server.note = note
    model_server.weight = weight
    db.session.add(model_server)
    db.session.commit()
    return UtilHelper.renderSucJSON()
Exemplo n.º 7
0
def link_set():
    if UtilHelper.isGet():
        req = request.values
        id = int(req['id']) if ('id' in req and req['id']) else 0
        info = None
        if id > 0:
            info = Link.query.filter_by(id=id).first()
        return UtilHelper.renderPopView(
            "home/link/set.html", {
                "info": info,
                "type_map": CommonConstant.link_type_map
            })

    req = request.values
    id = int(req['id']) if ('id' in req and req['id']) else 0
    type = int(req.get("type", 0).strip())
    title = req.get("title", "").strip()
    url = req.get("url", "").strip()
    weight = int(req.get("weight", 1).strip())

    if type < 1:
        return UtilHelper.renderErrJSON("请选择分类~~")

    if not ValidateHelper.validLength(title, 1, 30):
        return UtilHelper.renderErrJSON("请输入符合规范的标题~~")

    if not ValidateHelper.validUrl(url):
        return UtilHelper.renderErrJSON("请输入符合规范的网址~~")

    info = Link.query.filter_by(id=id).first()
    if info:
        model_link = info
    else:
        model_link = Link()

    model_link.type = type
    model_link.title = title
    model_link.url = url
    model_link.weight = weight
    db.session.add(model_link)
    db.session.commit()
    return UtilHelper.renderSucJSON()
Exemplo n.º 8
0
def dept_set():
    if UtilHelper.isGet() :
        req = request.values
        id = int( req['id'] ) if ( 'id' in req and req['id'] )else 0
        info = None
        query_role_list = Role.query.filter_by( pid = CommonConstant.default_status_false )
        if id > 0:
            info = Role.query.filter_by( id=id ).first()
            query_role_list = query_role_list.filter( Role.id != id )

        role_list = query_role_list.order_by( Role.id.desc() ).all()

        return UtilHelper.renderPopView( "home/rbac/dept/set.html",{ "info":info ,"role_list": role_list}  )

    req = request.values
    id = int(req['id']) if ('id' in req and req['id']) else 0
    name = req.get("name","").strip()
    pid = int( req.get("pid","0").strip() )


    if not ValidateHelper.validLength( name,1,10 ):
        return UtilHelper.renderErrJSON("请输入符合规范的姓名~~")

    info = Role.query.filter_by(id=id).first()
    if info:
        model_role = info
        #还不能选择自己的子节点

        if id == pid:
            return UtilHelper.renderErrJSON("不能勾选自己为所属部门哦~~")
    else:
        model_role = Role()

    model_role.name = name
    model_role.pid = pid
    db.session.add( model_role )
    db.session.commit()
    return UtilHelper.renderSucJSON()