本文整理汇总了Python中gluon.SQLFORM.add_button方法的典型用法代码示例。如果您正苦于以下问题:Python SQLFORM.add_button方法的具体用法?Python SQLFORM.add_button怎么用?Python SQLFORM.add_button使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gluon.SQLFORM
的用法示例。
在下文中一共展示了SQLFORM.add_button方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import add_button [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()
示例2: create
# 需要导入模块: from gluon import SQLFORM [as 别名]
# 或者: from gluon.SQLFORM import add_button [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()