当前位置: 首页>>代码示例>>Python>>正文


Python SQLFORM.accepts方法代码示例

本文整理汇总了Python中gluon.SQLFORM.accepts方法的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM.accepts方法的具体用法?Python SQLFORM.accepts怎么用?Python SQLFORM.accepts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gluon.SQLFORM的用法示例。


在下文中一共展示了SQLFORM.accepts方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: vendedor

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import accepts [as 别名]
def vendedor():

    title = "Cadastro de Vendedores"

    #lista todos os carros na tela
    vendedor_grid  = SQLFORM.smartgrid(db2.vendedor)

    #CRUD
    #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
    #mostra a mensagem de falha sozinho
    vendedor_crud = crud.create(db2.vendedor)

    ####SQL####################################################
    #######################################################
    #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
    #mas não mostra a mensagem de falha ou aceitação sozinho
    vendedor_sqlform = SQLFORM(db2.vendedor)

    if vendedor_sqlform.accepts(request,session):
        response.flash = 'Form accepted'
    elif vendedor_sqlform.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill the form'

    form_vendedor = detalhes_geral(db2.vendedor, 1)

    (form_crud,table_crud) = pesquisa_geral(db2.vendedor)

    return locals()
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:32,代码来源:veiculo.py

示例2: venda

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import accepts [as 别名]
def venda():

     if not session.flashed:
        response.flash = T('Bem vindo a tela de vendas!')

     title = "Venda"

     ####SQL####################################################
     #######################################################
     #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
     #mas não mostra a mensagem de falha ou aceitação sozinho
     venda_sqlform = SQLFORM(db2.venda)

     if venda_sqlform.accepts(request,session):
        response.flash = 'Form accepted'
        formulario = db2().select(db2.venda.ALL).last()
        fecha_venda(formulario)
     elif venda_sqlform.errors:
        response.flash = 'Form has errors'
     else:
        response.flash = 'Please fill the form'

     form_venda = detalhes_geral(db2.venda, 2)

     (form_crud,table_crud) = pesquisa_geral(db2.venda)

     return locals()
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:29,代码来源:veiculo.py

示例3: detalhes_geral

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import accepts [as 别名]
def detalhes_geral(tabela, tb_id):

    registro_geral = tabela(tb_id) or redirect(URL('Inicio'))

    form_geral =SQLFORM(tabela,registro_geral,deletable=True,upload=URL('veiculo','download'))

    if form_geral.accepts(request.vars,session):
        response.flash = 'Sucesso'
    elif form_geral.errors:
        response.flash = 'Erro'

    return form_geral
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:14,代码来源:veiculo.py

示例4: vendor_sqlform

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import accepts [as 别名]
def vendor_sqlform():
    """
    Create a simple form using the SQLFORM function of web2py.

    Some notes:
        The accepts function validates each field and write the results to de database.
    """

    vendor_sqlform = SQLFORM(db.vendor)

    if vendor_sqlform.accepts(request,session):
        response.flash = 'Form accepted'
    elif vendor_sqlform.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill the form'

    return locals()
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:20,代码来源:forms.py

示例5: carro

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import accepts [as 别名]
def carro():

    title = "Cadastro de Carros"

    if not session.flashed:
        response.flash = T('Bem vindo a loja de carros!')

    #lista todos os carros na tela
    car_grid = SQLFORM.smartgrid(db2.carro)

    #CRUD
    #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
    #mostra a mensagem de falha sozinho
    carro_crud = crud.create(db2.carro)

    #######################################################
    #aqui ele formata tudo sozinho e ainda envia para o banco sozinho também
    #mas não mostra a mensagem de falha ou aceitação sozinho
    carro_sqlform = SQLFORM(db2.carro)

    if carro_sqlform.accepts(request,session):
        response.flash = 'Form accepted'
    elif carro_sqlform.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill the form'

    excluir_carro(1)

    alterar_carro(2)

    #######################################################
     # Must repeat the field validators declared in the db.py
    marca_input=INPUT(_name='marca_input', requires=IS_IN_DB(db2, 'marca.id','marca.nome',error_message=e_m['not_in_db']))
    modelo_input=INPUT(_name='modelo_input')
    y1 = request.now.year-20
    y2 = request.now.year+2
    ano_input=INPUT(_name='ano_input', requires=IS_INT_IN_RANGE(y1,y2,error_message=e_m['not_in_range']))
    cor_input=INPUT(_name='cor_input', requires=IS_IN_SET(cores))
    valor_input=INPUT(_name='valor_input')
    itens_input=INPUT(_name='itens_input',requires=IS_IN_SET(('Alarme','Trava','Som', 'Ar'),multiple=True,error_message=e_m['not_in_set']))
    estado_input=INPUT(_name='estado_input',requires=IS_IN_SET(estados,error_message=e_m['not_in_set']))
    desc_input=INPUT(_name='desc_input')
    foto_input=INPUT(_name='foto_input',requires=IS_IMAGE(IS_IMAGE(extensions=('jpeg', 'png', '.gif'),error_message=e_m['image'])))

    #neste ponto define a posição dos dados dentro de uma tabela
    # Manual creation of the html table
    table_rows = []
    table_rows.append(TR('Marca:', marca_input))
    table_rows.append(TR('Modelo:', modelo_input))
    table_rows.append(TR('Ano:', ano_input))
    table_rows.append(TR('Cor:', cor_input))
    table_rows.append(TR('Valor:', valor_input))
    table_rows.append(TR('Itens:', itens_input))
    table_rows.append(TR('Estado:', estado_input))
    table_rows.append(TR('Descrição:', desc_input))
    table_rows.append(TR('Foto:', foto_input))
    # Fields starting with _ are passed to the html as attribute elements
    table_rows.append(TR(TD(INPUT(_type='submit'), _colspan='2', _align='center')))
    table = TABLE(table_rows)

    form = FORM(table)

    #momento em que realmente o dado é colocado dentro do banco de dados
    # Processing the form submition
    if form.accepts(request,session):
        # Retriving the form fields
        form_marca_input = form.vars.marca
        form_modelo_input = form.vars.modelo
        form_ano_input = form.vars.ano
        form_cor_input = form.vars.cor
        form_valor_input = form.vars.valor
        form_itens_input = form.vars.itens
        form_estado_input = form.vars.estado
        form_desc_input = form.vars.desc
        form_foto_input = form.vars.foto
        # Inserting in the database
        db.car_model.insert(marca=form_marca_input, modelo = form_modelo_input,ano = form_ano_input, cor = form_cor_input, valor = form_valor_input, itens = form_itens_input, estado = form_estado_input, desc = form_desc_input, foto = form_foto_input)
        # Tell the user about the insertion
        response.flash = 'New car: ' + form_modelo_input
    elif form.errors:
        response.flash = 'Form has errors'
    else:
        response.flash = 'Please fill the form'

    #######################################################
    form_carro = detalhes_geral(db2.carro,2)

    (form_crud,table_crud) = pesquisa_geral(db2.carro)

    return locals()
开发者ID:JulianaTec,项目名称:TesteRepositorio3,代码行数:93,代码来源:veiculo.py


注:本文中的gluon.SQLFORM.accepts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。