예제 #1
0
def login():
    set_cookie('AUTHTOKEN', '', 0)
    ctx = {
        'username': strings.strip_to_empty(get_cookie('USERNAME')),
        'sourceurl': request.args.get('url'),
        'otpenabled': setting.get_bool('system.otp.enabled')
    }
    return render_template('login.html', **ctx)
예제 #2
0
def save():
    oid = request.form.get("id")
    parentid = strings.strip_to_empty(request.form.get('parentid', ''))
    menu = {}
    if strings.is_not_blank(oid):
        menu = get_menu(oid)
        if menu is None:
            menu = {}
    else:
        menu['sort'] = find_menu(parentid=parentid).count() + 1
    menu["name"] = request.form.get("name", '')
    menu['type'] = num.safe_int(request.form.get('type', 0))
    menu["url"] = request.form.get("url", None)
    menu["target"] = request.form.get("target", None)
    menu['parentid'] = parentid
    menu['icon'] = request.form.get('icon', '')
    menu['mark'] = request.form.get('mark', '')
    save_menu(menu)
    return "success"
예제 #3
0
파일: views.py 프로젝트: major1201/raphael
def services_save():
    cn = request.form.get('cn')
    services = request.form.get('services')
    if strings.is_blank(services):
        return '服务不能为空!'
    service_list = list(
        filter(lambda s: strings.is_not_empty(s),
               map(lambda x: strings.strip_to_empty(x), services.split('\n'))))
    _type = request.form.get('type')
    if _type == 'NEW':
        if models.add_service(cn, authorized_service=service_list):
            return 'success'
        else:
            return '保存失败'
    elif _type == 'EDIT':
        if models.modify_service(cn, authorizedService=service_list):
            return 'success'
        else:
            return '保存失败'
    else:
        return 'Unknown type: %s' % _type
예제 #4
0
파일: views.py 프로젝트: major1201/raphael
def commands_save():
    cn = request.form.get('cn')
    commands = request.form.get('commands')
    if strings.is_blank(commands):
        return '命令不能为空!'
    command_list = list(
        filter(lambda s: strings.is_not_empty(s),
               map(lambda x: strings.strip_to_empty(x), commands.split('\n'))))
    _type = request.form.get('type')
    if _type == 'NEW':
        if models.add_command(cn, sudo_command=command_list):
            return 'success'
        else:
            return '保存失败'
    elif _type == 'EDIT':
        if models.modify_command(cn, sudoCommand=command_list):
            return 'success'
        else:
            return '保存失败'
    else:
        return 'Unknown type: %s' % _type
예제 #5
0
def table():
    parentid = strings.strip_to_empty(g.params.get('qparentid'))
    return find_menu(parentid=parentid)
예제 #6
0
 def delete_byid(self, table_name, oid):
     oid = strings.strip_to_empty(oid)
     self.execute_delete(table_name, "id=:id", id=oid)