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


Python SQLFORM.process方法代码示例

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


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

示例1: create

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def create():
    """Create a new organization"""
    tbl = db.organization
    tbl.users.readable = False
    tbl.users.writable = False
    tbl.desks.readable = False
    tbl.desks.writable = False
    tbl.name.requires = [
        IS_NOT_EMPTY(
            error_message=T("Cannot be empty")
        ),
        IS_NOT_IN_DB(
            db,
            'organization.name',
            error_message=T(
                "An Organization witch that name is allready in nStock"))]

    form = SQLFORM(tbl)
    form.add_button(T('Cancel'), URL('index'))

    if form.process().accepted:
        # add the new organization
        g_id = auth.user_group(auth.user.id)
        # give the user all perms over this org
        auth.add_permission(g_id, 'update', tbl, form.vars.id)
        auth.add_permission(g_id, 'read', tbl, form.vars.id)
        auth.add_permission(g_id, 'delete', tbl, form.vars.id)
        redirect(URL('index'))

    return locals()
开发者ID:ybenitezf,项目名称:nstock,代码行数:32,代码来源:org.py

示例2: inserir

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def inserir():
    u"""Permite inserir um novo registro.

    Um registro pode ser:
        - Uma notícia;
        - Um evento;
        - Um produto;
        - Um membro;
        - Um apoiador.
    Observação: Somente usuários com permissão de admin podem inserir novos
    membros e apoiadores.
    """
    argumento = current.request.args(0) or redirect(URL('default', 'index'))
    lista_tabelas = ['noticias', 'eventos', 'produtos']
    auth = current.globalenv['auth']
    db = current.globalenv['db']
    if auth.has_membership('admin'):
        lista_tabelas.extend(['membros', 'apoiadores'])
    if argumento not in lista_tabelas:
        current.session.flash = current.T(
            'Operação não permitida a seu usuário.'
        )
        redirect(URL('admin', 'listar', args='noticias'))
    form = SQLFORM(
        db[argumento], submit_button="Enviar",
        formstyle='bootstrap3_stacked')
    if form.process().accepted:
        current.response.flash = 'Registro inserido com sucesso!'
    elif form.errors:
        current.response.flash = 'Formulário contem erros'
    return {'argumento': argumento, 'form': form}
开发者ID:augustopedro,项目名称:marolo,代码行数:33,代码来源:admin.py

示例3: editform

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def editform():
    """
    Return a sqlform object for editing the specified slide.
    """
    sid = session.plugin_slider_sid
    form = SQLFORM(db.plugin_slider_slides, sid,
                   separator='',
                   deletable=True,
                   showid=True)

    if form.process(formname='plugin_slider_slides/{}'.format(sid)).accepted:
        response.flash = 'The changes were recorded successfully.'
    elif form.errors:
        print('\n\nlistandedit form errors:')
        pprint({k: v for k, v in form.errors.items()})
        print('\n\nlistandedit form vars')
        pprint({k: v for k, v in form.vars.items()})
        print('\n\nlistandedit request vars')
        pprint({k: v for k, v in request.vars.items()})
        response.flash = 'Sorry, there was an error processing ' \
                         'the form. The changes have not been recorded.'

    else:
        pass

    return form
开发者ID:monotasker,项目名称:plugin_slider,代码行数:28,代码来源:plugin_slider.py

示例4: getEditgameUpdateForm

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def getEditgameUpdateForm (game):
	"""
	Gets an update for the edit game page.

	Keyword Arguments:
	game -- row representing the current game

	Return Values:
	formUpdate -- web2py form
	"""

	from gluon import current, redirect, URL, SQLFORM
	db = current.db

	#Hide some fields of the form
	hideFields (db.game, ['id', 'host_id', 'game_status', 'password'])

	formUpdate = SQLFORM(db.game, game.id)
	formUpdate.add_class('assassins-form')

	if formUpdate.process().accepted:
		resizeImage(db.game, game.id)
		redirect(getUrl('edit', game.id))

	return formUpdate
开发者ID:bejbej,项目名称:assassins,代码行数:27,代码来源:game.py

示例5: create

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def create():
    org = db.organization(session.org_id)
    tbl = db.desk
    tbl.item_list.readable = False
    tbl.item_list.writable = False
    tbl.name.requires = IS_NOT_EMPTY()

    form = SQLFORM(db.desk)
    form.add_button(T('Cancel'), URL('org', 'view', args=[org.id]))

    if form.process().accepted:
        # add the new desk to the org list
        desk_id = form.vars.id
        # add current users as the one with permission to update manage
        # this desk
        auth.add_permission(
            auth.user_group(auth.user.id),
            'update',
            db.desk,
            desk_id)
        desk_list = org.desks
        desk_list.insert(0, desk_id)
        org.update_record(desks=desk_list)
        # return to the org desk list
        redirect(URL('org', 'view', args=[org.id]))

    return locals()
开发者ID:ybenitezf,项目名称:nstock,代码行数:29,代码来源:desk.py

示例6: inserir

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def inserir():
    """Insere um novo banner."""
    db = current.globalenv['db']
    form = SQLFORM(
        db.carousel, submit_button="Enviar",
        formstyle='bootstrap3_stacked')
    if form.process().accepted:
        current.response.flash = 'Registro inserido com sucesso!'
    elif form.errors:
        current.response.flash = 'Formulário contem erros'
    return {'form': form}
开发者ID:augustopedro,项目名称:marolo,代码行数:13,代码来源:banners.py

示例7: edit

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def edit():
    desk = db.desk(request.args(0))
    session.desk_id = desk.id

    db.desk.item_list.readable = False
    db.desk.item_list.writable = False
    form = SQLFORM(db.desk, record=desk, showid=False)

    if form.process().accepted:
        redirect(URL('index', args=[desk.id]))

    return locals()
开发者ID:ybenitezf,项目名称:nstock,代码行数:14,代码来源:desk.py

示例8: edit

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def edit():
    org = db.organization(request.args(0))
    tbl = db.organization
    tbl.users.readable = False
    tbl.users.writable = False
    tbl.desks.readable = False
    tbl.desks.writable = False
    tbl.name.requires = [IS_NOT_EMPTY()]

    # edit form
    form = SQLFORM(db.organization, record=org, showid=False)
    if form.process().accepted:
        redirect(URL('view', args=[org.id]))

    return locals()
开发者ID:ybenitezf,项目名称:nstock,代码行数:17,代码来源:org.py

示例9: meta

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def meta():
    """
    Edit/Show item metadata info
    """
    item = application.getItemByUUID(request.args(0))

    if item is None:
        raise HTTP(404)

    contentType = application.getContentType(item.item_type)
    l_names = [
        (r.language_tag, r.english_name) for r in db(
            db.languages.id > 0
        ).select(orderby=db.languages.english_name)
    ]
    db.item.language_tag.requires = IS_IN_SET(
        l_names,
        zero=None
    )

    # issue #5 hidde some fields from metadata
    db.item.provider.readable = False
    db.item.provider.writable = False
    db.item.provider_service.readable = False
    db.item.provider_service.writable = False
    db.item.copyright_holder.readable = False
    db.item.copyright_holder.writable = False
    db.item.copyright_url.readable = False
    db.item.copyright_url.writable = False
    db.item.copyright_notice.readable = False
    db.item.copyright_notice.writable = False
    db.item.pubstatus.readable = False
    db.item.pubstatus.writable = False

    form = SQLFORM(db.item, record=item)

    if form.process().accepted:
        # session.flash = "Done !"
        # send an email to all the users who has access to this item
        application.notifyChanges(item.unique_id)
        application.indexItem(item.unique_id)
        if request.ajax:
            response.js = "$('#metaModal').modal('hide');"
        else:
            redirect(application.getItemURL(item.unique_id))

    return locals()
开发者ID:ybenitezf,项目名称:nstock,代码行数:49,代码来源:item.py

示例10: index

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def index():
    """
    Edit/Show package content
    """
    pkg_item = application.getItemByUUID(request.args(0))
    content = db.plugin_package_content(item_id=pkg_item.unique_id)

    form = SQLFORM(
        db.plugin_package_content,
        record=content,
        showid=False)

    if form.process().accepted:
        application.indexItem(pkg_item.unique_id)
        redirect(URL('default', 'index'))

    return locals()
开发者ID:ybenitezf,项目名称:nstock,代码行数:19,代码来源:plugin_package.py

示例11: linked_create_form

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def linked_create_form():
    """
    creates a form to insert a new entry into the linked table which populates
    the ajaxSelect widget
    """
    print 'Starting linked_create_form'
    try:
        tablename = request.args[0]
        fieldname = request.args[1]
        wrappername = request.vars['wrappername']
        table = db[tablename]
        field = table[fieldname]

        linktable = get_linktable(field)

        formname = '{}_create'.format(wrappername)
        form = SQLFORM(db[linktable])

        comp_url = URL('plugin_ajaxselect', 'set_widget.load',
                    args=[tablename, fieldname],
                    vars=request.vars)

        if form.process(formname=formname).accepted:
            response.flash = 'form accepted'
            response.js = "window.setTimeout(" \
                          "web2py_component('{}', '{}'), " \
                          "500);".format(comp_url, wrappername)

            print 'linked create form accepted'
            print 'linked create form vars:'
            pprint(form.vars)
        if form.errors:
            response.error = 'form was not processed'
            response.flash = 'form was not processed'
            print 'error processing linked_create_form'
            print form.errors
        else:
            print 'form not processed but no errors'
            pass

    except Exception:
        import traceback
        print traceback.format_exc(5)
        form = traceback.format_exc(5)

    return dict(form=form)
开发者ID:shenjiawei19,项目名称:plugin_ajaxselect,代码行数:48,代码来源:plugin_ajaxselect.py

示例12: create_grade

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def create_grade():
    """
    TODO: Make sure these fields are all required.
    TODO: Restrict names in drop-down to students in current course
    TODO: Remove logged-in student from name drop-down
    """
    c = ''
    if request.args:
        c = db.courses[request.args[0]]
    else:
        redirect(URL('index'))
    cname = c.course_name
    cnum = c.id
    m = str(c.max_score)
    if m in [None, 'None']:
        m = '10'

    class_members = db(db.course_membership.course == cnum).select()
    member_nums = [member['id'] for member in class_members]
    print 'member_nums', member_nums
    mquery = db(db.auth_user.id.belongs(
                    db(db.course_membership.course == cnum)._select(db.course_membership.name)
                                        ))
    db.grades.name.requires = IS_IN_DB(mquery, 'auth_user.id', '%(last_name)s, %(first_name)s')
    form = SQLFORM(
        db.grades,
        separator='',
        fields=['name', 'grade', 'class_date'],
        labels={'name': "Student's name",
                'grade': "Grade",
                'class_date': 'Class date'},
        col3={'name': 'The student to receive the grade.',
              'grade': 'a number out of {}'.format(m),
              'class_date': "the date when the class took place"},
        submit_button='assign this grade'
        )
    form.vars.course = cnum
    if form.process().accepted:
        response.flash = 'Thanks! The grade was recorded.'

    the_user = db(db.auth_user.id == auth.user_id).select().first()
    fn = the_user.first_name
    return dict(form=form,
                fn=fn,
                cname=cname,
                courseid=cnum)
开发者ID:monotasker,项目名称:grades,代码行数:48,代码来源:default.py

示例13: editar

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def editar():
    """Deleta ou edita um banner modificando seus atributos."""
    cod = current.request.args(0, cast=int, otherwise=URL('default', 'index'))
    db = current.globalenv['db']
    form = SQLFORM(
        db.carousel,
        cod,
        deletable=True,
        showid=False, submit_button="Enviar",
        upload=URL('default', 'download'), formstyle="bootstrap3_stacked"
    )

    if form.process().accepted:
        current.session.flash = 'Registro editado com sucesso'
        redirect(URL('banners', 'listar'))
    elif form.errors:
        current.session.flash = 'Formulário contem erros'
    return {'form': form}
开发者ID:augustopedro,项目名称:marolo,代码行数:20,代码来源:banners.py

示例14: addform

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def addform():
    """
    Return a sqlform object for editing the specified slide.
    """
    did = request.args[0]
    direction = request.vars.direction
    sid = session.plugin_slider_sid
    deckorder = session.plugin_slider_deckorder
    # get index for inserting new slide
    sindex = deckorder.index(sid)
    newindex = sindex + 1
    if newindex == len(deckorder) or direction == 'before':
        newindex = sindex

    form = SQLFORM(db.plugin_slider_slides,
                   separator='',
                   deletable=True,
                   showid=True,
                   formname='plugin_slider_slides/addnew')
    if form.process(formname='plugin_slider_slides/addnew').accepted:
        deckrow = db.plugin_slider_decks(did)
        # TODO: is this the best way to get the new slide id?
        slideid = db(db.plugin_slider_slides).select().last().id
        deckslides = deckrow.deck_slides
        deckslides.insert(sindex, slideid)
        deckrow.update_record(deck_slides=deckslides)
        response.flash = 'The new slide was added successfully.'
    elif form.errors:
        print('\n\nlistandedit form errors:')
        pprint({k: v for k, v in form.errors.items()})
        print('\n\nlistandedit form vars')
        pprint({k: v for k, v in form.vars.items()})
        print('\n\nlistandedit request vars')
        pprint({k: v for k, v in request.vars.items()})
        response.flash = 'Sorry, there was an error processing ' \
                         'the form. The changes have not been recorded.'

    else:
        pass

    return form
开发者ID:monotasker,项目名称:plugin_slider,代码行数:43,代码来源:plugin_slider.py

示例15: linked_edit_form

# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import process [as 别名]
def linked_edit_form():
    """
    creates a form to edit, update, or delete an intry in the linked table which
    populates the AjaxSelect widget.
    """
    try:
        tablename = request.args[0]
        fieldname = request.args[1]
        table = db[tablename]
        field = table[fieldname]

        req = field.requires if isinstance(field.requires, list) else [field.requires]
        linktable = req[0].ktable

        this_row = request.args[2]
        wrappername = request.vars['wrappername']
        formname = '{}/edit'.format(tablename)

        form = SQLFORM(db[linktable], this_row)

        comp_url = URL('plugin_ajaxselect', 'set_widget.load',
                       args=[tablename, fieldname],
                       vars=request.vars)

        if form.process(formname=formname).accepted:
            response.flash = 'form accepted'
            response.js = "web2py_component('%s', '%s');" % (comp_url, wrappername)
        if form.errors:
            response.error = 'form was not processed'
            print 'error processing linked_create_form'
            print form.errors
        else:
            pass
    except Exception:
        import traceback
        print 'error in whole of linked_edit_form'
        print traceback.format_exc(5)
        form = traceback.format_exc(5)

    return {'form': form}
开发者ID:tazjel,项目名称:plugin_ajaxselect,代码行数:42,代码来源:plugin_ajaxselect.py


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