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


Python SQLFORM.smartgrid方法代码示例

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


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

示例1: vendedor

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import smartgrid [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: grades_manage

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import smartgrid [as 别名]
def grades_manage():
    #get course id passed as first argument of url
    this_course = request.args[0]
    coursename = db(db.courses.id == this_course).select().first().course_name
    #create smartgrid to display all class grades
    form = SQLFORM.smartgrid(db.grades,
                             fields=[db.grades.name,
                                     db.grades.grade,
                                     db.grades.class_date],
                             constraints={'grades': db.grades.course == this_course},
                             onupdate=auth.archive,
                             paginate=300,
                             args=[this_course])
    return locals()
开发者ID:monotasker,项目名称:grades,代码行数:16,代码来源:default.py

示例3: classes_manage

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import smartgrid [as 别名]
def classes_manage():
    form = SQLFORM.smartgrid(db.courses, onupdate=auth.archive)
    return locals()
开发者ID:monotasker,项目名称:grades,代码行数:5,代码来源:default.py

示例4: carro

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import smartgrid [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

示例5: grid

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import smartgrid [as 别名]
    def grid(self):
        fields = dict(auth_user=[self.db.auth_user.first_name, self.db.auth_user.email,
                                 self.db.auth_user.registration_key])

        self.db.auth_user.registration_key.readable = True
        if str2bool(self.config.take('auth_local.admin_registration_requires_verification')):
            self.db.auth_user.password.readable = False
            self.db.auth_user.password.writable = False
        else:
            self.db.auth_user.password.readable = True
            self.db.auth_user.password.writable = True

        fields["auth_user"][2].represent = lambda value, row: SPAN('active', _class='label label-success') \
            if value == "" else SPAN(value, _class='label label-info')

        links = dict(auth_user=[
            lambda row: A('Enable',  _class="btn-success btn-mini", callback=URL('users', 'action', args=[str(row.id), 'enable']))
            if row.registration_key == 'blocked' or row.registration_key == 'disabled' else "",
            lambda row: A('Block', _class="btn-danger btn-mini", callback=URL('users', 'action', args=[str(row.id), 'block']))
            if row.registration_key == '' else "",
            lambda row: A('Approve', _class="btn btn-info btn-mini", callback=URL('users', 'action', args=[str(row.id), 'enable']))
            if row.registration_key == 'pending' else "",])

        def verify_email(form):
            from gluon.utils import web2py_uuid
            if str2bool(self.config.take('auth_local.admin_registration_requires_verification')):
                d = dict(form.vars)
                key = web2py_uuid()
                link = URL('default', 'user', args=('verify_email', key), scheme=True)
                d = dict(form.vars)
                plain_password = web2py_uuid().split('-')[0]
                md5_password = self.db.auth_user.password.validate(plain_password)[0]
                d.update(dict(registration_key=key, password=md5_password))
                self.db(self.db['auth_user']._id==form.vars.id).update(**d)

                from myapp import Mailer
                notification = Mailer()
                if notification.send_email(form.vars.email, 'VERIFY YOUR EMAIL', 'verify_email', link=link, password=plain_password):
                    self.session.flash = "Email sent to the user for verification"
                else:
                    self.session.flash = "Email unsent, uppss there is a error"


        linked_tables = ['auth_membership']

        if self.config.take('general.auth_type') == 'local':
            grid = SQLFORM.smartgrid(self.db.auth_user,
                                     ui='web2py',
                                     linked_tables=linked_tables,
                                     fields=fields,
                                     #orderby=fields[-2],
                                     links=links,
                                     csv=False,
                                     searchable=True,
                                     create=True,
                                     details=True,
                                     editable=True,
                                     deletable=True,
                                     oncreate=verify_email,)
        else:
            grid = SQLFORM.smartgrid(self.db.auth_user,
                                     ui='web2py',
                                     linked_tables=linked_tables,
                                     fields=fields,
                                     #orderby=fields[-2],
                                     links=links,
                                     csv=False,
                                     searchable=True,
                                     create=False,
                                     details=True,
                                     editable=False,
                                     deletable=True)

        return grid
开发者ID:engeens,项目名称:reamker,代码行数:76,代码来源:users.py

示例6: grid

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import smartgrid [as 别名]
    def grid(self):
        fields = dict(
            auth_user=[self.db.auth_user.first_name, self.db.auth_user.email, self.db.auth_user.registration_key]
        )

        self.db.auth_user.registration_key.readable = True
        if str2bool(self.config.take("auth_local.admin_registration_requires_verification")):
            self.db.auth_user.password.readable = False
            self.db.auth_user.password.writable = False
        else:
            self.db.auth_user.password.readable = True
            self.db.auth_user.password.writable = True

        fields["auth_user"][2].represent = (
            lambda value, row: SPAN("active", _class="label label-success")
            if value == ""
            else SPAN(value, _class="label label-info")
        )

        links = dict(
            auth_user=[
                lambda row: A(
                    "Enable",
                    _class="btn-success btn-mini",
                    callback=URL("users", "action", args=[str(row.id), "enable"]),
                )
                if row.registration_key == "blocked" or row.registration_key == "disabled"
                else "",
                lambda row: A(
                    "Block", _class="btn-danger btn-mini", callback=URL("users", "action", args=[str(row.id), "block"])
                )
                if row.registration_key == ""
                else "",
                lambda row: A(
                    "Approve",
                    _class="btn btn-info btn-mini",
                    callback=URL("users", "action", args=[str(row.id), "enable"]),
                )
                if row.registration_key == "pending"
                else "",
            ]
        )

        def verify_email(form):
            from gluon.utils import web2py_uuid

            if str2bool(self.config.take("auth_local.admin_registration_requires_verification")):
                d = dict(form.vars)
                key = web2py_uuid()
                link = URL("default", "users", args=("verify_email", key), scheme=True)
                d = dict(form.vars)
                plain_password = web2py_uuid().split("-")[0]
                md5_password = self.db.auth_user.password.validate(plain_password)[0]
                d.update(dict(registration_key=key, password=md5_password))
                self.db(self.db["auth_user"]._id == form.vars.id).update(**d)

                from myapp import Mailer

                notification = Mailer()
                if notification.send_email(
                    form.vars.email, "VERIFY YOUR EMAIL", "verify_email", link=link, password=plain_password
                ):
                    self.session.flash = "Email sent to the user for verification"
                else:
                    self.session.flash = "Email unsent, uppss there is a error"

        linked_tables = [self.db.auth_membership]
        if self.config.take("general.auth_type") == "local":
            grid = SQLFORM.smartgrid(
                self.db.auth_user,
                ui="web2py",
                fields=fields,
                links=links,
                linked_tables=linked_tables,
                # orderby=fields[-2],
                csv=False,
                searchable=True,
                create=True,
                details=True,
                editable=True,
                deletable=True,
                oncreate=verify_email,
            )
        else:
            grid = SQLFORM.smartgrid(
                self.db.auth_user,
                ui="web2py",
                linked_tables=linked_tables,
                fields=fields,
                # orderby=fields[-2],
                links=links,
                csv=False,
                searchable=True,
                create=False,
                details=True,
                editable=False,
                deletable=True,
            )

        return grid
开发者ID:engeens,项目名称:pangolin,代码行数:102,代码来源:users.py


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