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


Python gluon.IS_IN_SET属性代码示例

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


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

示例1: meta

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

示例2: share

# 需要导入模块: import gluon [as 别名]
# 或者: from gluon import IS_IN_SET [as 别名]
def share():
    """
    Show the list of desk to with the item can be push
    """
    item = application.getItemByUUID(request.args(0))
    if item is None:
        raise HTTP(404)

    query = (db.desk.id != session.desk_id)
    query &= auth.accessible_query('push_items', db.desk)

    posible_desk = db(query).select()

    fld_to_desk = Field('to_desk', 'integer')
    fld_to_desk.label = T("Push to organization desk")
    fld_to_desk.comment = T("Select where to push the item")
    fld_to_desk.requires = IS_EMPTY_OR(IS_IN_SET(
        [(desk.id, desk.name) for desk in posible_desk]
    ))

    fld_personal_desk = Field('to_person_desk', 'integer')
    fld_personal_desk.label = T("Push to other person desk")
    fld_personal_desk.comment = T("Select a person from the list.")
    # list of person on orgs
    persons = []
    # search up all the persons
    orgs = db(db.organization.users.contains(auth.user.id)).select()
    for org in orgs:
        x = [db.auth_user(id=y) for y in org.users if y != auth.user.id]
        persons.extend(x)
    persons = list(set(persons))
    fld_personal_desk.requires = IS_EMPTY_OR(IS_IN_SET(
        [(per.id, "{} {}".format(per.first_name, per.last_name)) for per in persons]
    ))

    fld_cond = Field('cond', 'boolean', default=False)
    fld_cond.label = T('To other person?')

    form = SQLFORM.factory(
        fld_to_desk,
        fld_personal_desk,
        fld_cond,
        submit_button=T("Send"),
        table_name='share')
    if form.process().accepted:
        src = session.desk_id
        if form.vars.cond:
            # send the item to other user
            other_user = db.auth_user(form.vars.to_person_desk)
            target = application.getUserDesk(other_user).id
        else:
            # send the item to the selected desk
            target = form.vars.to_desk

        if target:
            ct = application.getContentType(item.item_type)
            ct.shareItem(item.unique_id, src, target)
        response.js = "$('#metaModal').modal('hide');"
        response.flash = None

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


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