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


Python current.T属性代码示例

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


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

示例1: getUserDesk

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def getUserDesk(self, user=None):
        db = self.db
        auth = self.auth
        if user is None:
            user = auth.user

        # setup user desk if necessary.
        user_desk = db(
            auth.accessible_query('owner', db.desk, user.id)).select().first()
        if user_desk is None:
            name = self.T("%s desk", (auth.user.first_name,))
            desk_id = db.desk.insert(name=name)
            g_id = auth.user_group(auth.user.id)
            auth.add_permission(g_id, 'owner', db.desk, desk_id)
            user_desk = db.desk(desk_id)

        return user_desk 
开发者ID:ybenitezf,项目名称:nstock,代码行数:19,代码来源:app.py

示例2: notifyChanges

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def notifyChanges(self, item_id):
        response = self.response
        auth = self.auth
        T = self.T
        item = self.getItemByUUID(item_id)

        message = response.render(
            'changes_email.txt',
            dict(item=item, user=auth.user)
        )
        subject = T("Changes on %s") % (item.headline,)

        self.notifyCollaborators(
            item.unique_id,
            subject,
            message
        ) 
开发者ID:ybenitezf,项目名称:nstock,代码行数:19,代码来源:app.py

示例3: index

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def index():
    """
    Edit content
    """
    item = application.getItemByUUID(request.args(0))

    db.plugin_picture_info.renditions.readable = False
    db.plugin_picture_info.renditions.writable = False

    content = db.plugin_picture_info(item_id=item.unique_id)

    form = SQLFORM(
        db.plugin_picture_info,
        record=content,
        showid=False,
        submit_button=T('Save'))

    if form.process().accepted:
        application.notifyChanges(item.unique_id)
        application.indexItem(item.unique_id)
        response.flash = None

    return dict(form=form, item=item, content=content) 
开发者ID:ybenitezf,项目名称:nstock,代码行数:25,代码来源:plugin_picture.py

示例4: edit_form

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def edit_form():
    item = application.getItemByUUID(request.args(0))
    content = db.plugin_photoset_content(item_id=item.unique_id)

    db.plugin_photoset_content.photoset.readable = False
    db.plugin_photoset_content.photoset.writable = False
    db.plugin_photoset_content.item_id.readable = False
    db.plugin_photoset_content.item_id.writable = False
    db.plugin_photoset_content.credit_line.requires = IS_NOT_EMPTY()

    form = SQLFORM(
        db.plugin_photoset_content,
        record=content,
        showid=False,
        submit_button=T('Save')
    )

    if form.process().accepted:
        application.notifyChanges(item.unique_id)
        application.indexItem(item.unique_id)
        response.flash = T('Saved')

    return form 
开发者ID:ybenitezf,项目名称:nstock,代码行数:25,代码来源:plugin_photoset.py

示例5: index

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def index():
    """
    Edit content
    """
    item = application.getItemByUUID(request.args(0))
    if item is None:
        raise HTTP(404)

    content = db.plugin_text_text(item_id=item.unique_id)

    form = SQLFORM(
        db.plugin_text_text,
        record=content,
        showid=False,
        submit_button=T('Save'))

    if form.process().accepted:
        application.notifyChanges(item.unique_id)
        application.indexItem(item.unique_id)
        redirect(application.getItemURL(item.unique_id))
        response.flash = T('Done')

    return dict(form=form, item=item, content=content) 
开发者ID:ybenitezf,项目名称:nstock,代码行数:25,代码来源:plugin_text.py

示例6: test_plain

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def test_plain(self):
        T = languages.translator(self.langpath, self.http_accept_language)
        self.assertEqual(str(T('Hello World')),
                         'Hello World')
        self.assertEqual(str(T('Hello World## comment')),
                         'Hello World')
        self.assertEqual(str(T('%s %%{shop}', 1)),
                         '1 shop')
        self.assertEqual(str(T('%s %%{shop}', 2)),
                         '2 shops')
        self.assertEqual(str(T('%s %%{shop[0]}', 1)),
                         '1 shop')
        self.assertEqual(str(T('%s %%{shop[0]}', 2)),
                         '2 shops')
        self.assertEqual(str(T('%s %%{quark[0]}', 1)),
                         '1 quark')
        self.assertEqual(str(T('%s %%{quark[0]}', 2)),
                         '2 quarks')
        self.assertEqual(str(T.M('**Hello World**')),
                         '<strong>Hello World</strong>')
        T.force('it')
        self.assertEqual(str(T('Hello World')),
                         'Salve Mondo') 
开发者ID:HackPucBemobi,项目名称:touch-pay-client,代码行数:25,代码来源:test_languages.py

示例7: _

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def _():
    tbl = db.define_table(
        'plugin_comment_comment',
        Field('body', 'text', label=T('Your comment')),
        Field('item_id', 'string', length=64),
        auth.signature,
    )
    tbl.item_id.readable = False
    tbl.item_id.writable = False
    tbl.body.requires = IS_NOT_EMPTY()

    return lambda item_id: LOAD(
        'plugin_comment', 'index.load', args=[item_id], ajax=True) 
开发者ID:ybenitezf,项目名称:nstock,代码行数:15,代码来源:plugin_comment.py

示例8: _

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def _():
    plugins = PluginManager('package', app=None)
    if plugins.package.app is not None:
        # this will register the the application on content/type
        plugins.package.app.registerContentType('package', ContentPackage())

        if not hasattr(db, 'plugin_package_content'):
            editor = CKEditor(db=db)
            tbl = db.define_table(
                'plugin_package_content',
                Field('item_list', 'list:string'),
                Field('description', 'text'),
                Field('item_id', 'string', length=64),
                auth.signature,
            )
            tbl.item_id.writable = False
            tbl.item_id.readable = False
            tbl.item_list.writable = False
            tbl.item_list.readable = False
            tbl.description.label = T('Description')
            tbl.description.widget = editor.widget
            tbl._enable_record_versioning()

            # add a callback to the item table for updating the item list of
            # the package on item deletion.
            def plugin_package_callback(s):
                item = s.select().first()
                # this are the packages with contains the item to delete
                pkgs = db(
                    db.plugin_package_content.item_list.contains(
                        item.unique_id)
                ).select()
                for pkg in pkgs:
                    # remove the item from the package
                    pkg.item_list.remove(item.unique_id)
                    pkg.update_record()

                return False
            db.item._before_delete.insert(0, plugin_package_callback) 
开发者ID:ybenitezf,项目名称:nstock,代码行数:41,代码来源:plugin_package.py

示例9: _

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def _():
    plugins = PluginManager('text', app=None)
    if plugins.text.app is not None:
        # this will register the content/type on the application
        plugins.text.app.registerContentType('text', ContentText())
        if not hasattr(db, 'plugin_text_text'):
            # configure ckeditor
            editor = CKEditor(db=db)
            # definimos la BD
            tbl = db.define_table(
                'plugin_text_text',
                Field('byline', 'string', length=250, default=''),
                Field('body', 'text', label=T('Content'), default=''),
                Field('item_id', 'string', length=64),
                auth.signature,
            )
            tbl.byline.label = T('By line')
            tbl.item_id.readable = False
            tbl.item_id.writable = False
            tbl.body.requires = IS_NOT_EMPTY()
            tbl.body.widget = editor.widget

            # enable record  versioning
            tbl._enable_record_versioning()

    return 
开发者ID:ybenitezf,项目名称:nstock,代码行数:28,代码来源:plugin_text.py

示例10: _

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def _():
    # add items menu
    create_items = []
    registry = application.registry
    for content_type in registry:
        icon = registry[content_type].get_icon()
        name = registry[content_type].get_name()
        url = URL('item', 'create.html', args=[content_type])
        create_items.append(
            (CAT(icon, ' ', name), False, url, [])
        )
    response.menu += [(T('Add Items'), False, "#", create_items)] 
开发者ID:ybenitezf,项目名称:nstock,代码行数:14,代码来源:z_menu.py

示例11: changelog

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def changelog():
    item = application.getItemByUUID(request.args(0))
    pic_info = db.plugin_picture_info(item_id=item.unique_id)

    query = (db.plugin_picture_info_archive.current_record == pic_info.id)
    db.plugin_picture_info_archive.modified_on.label = T('Date & Time')
    db.plugin_picture_info_archive.modified_on.readable = True
    db.plugin_picture_info_archive.modified_by.label = T('User')
    db.plugin_picture_info_archive.modified_by.readable = True
    fields = [
        db.plugin_picture_info_archive.modified_on,
        db.plugin_picture_info_archive.modified_by
    ]

    def gen_links(row):
        diff = A(
            SPAN(_class="glyphicon glyphicon-random"),
            _href=URL(
                'diff',
                args=[item.unique_id, row.id]),
            _class="btn btn-default",
            _title=T("Differences"),
        )

        return CAT(diff)

    links = [dict(header='', body=gen_links)]

    changes = SQLFORM.grid(
        query,
        orderby=[~db.plugin_picture_info_archive.modified_on],
        fields=fields,
        args=request.args[:1],
        create=False, editable=False, details=False, deletable=False,
        searchable=False,
        csv=False,
        links=links,
    )

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

示例12: changelog

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def changelog():
    item = application.getItemByUUID(request.args(0))
    pkg_content = db.plugin_package_content(item_id=item.unique_id)
    query = (
        db.plugin_package_content_archive.current_record == pkg_content.id)
    db.plugin_package_content_archive.modified_on.label = T('Date & Time')
    db.plugin_package_content_archive.modified_on.readable = True
    db.plugin_package_content_archive.modified_by.label = T('User')
    db.plugin_package_content_archive.modified_by.readable = True
    fields = [
        db.plugin_package_content_archive.modified_on,
        db.plugin_package_content_archive.modified_by
    ]

    def gen_links(row):
        diff = A(SPAN(
            _class="glyphicon glyphicon-random"),
            _href=URL(
                'diff',
                args=[item.unique_id, row.id]),
            _class="btn btn-default",
            _title=T("Differences"),
        )

        return CAT(diff)

    links = [dict(header='', body=gen_links)]

    changes = SQLFORM.grid(
        query,
        orderby=[~db.plugin_package_content_archive.modified_on],
        fields=fields,
        args=request.args[:1],
        create=False, editable=False, details=False, deletable=False,
        searchable=False,
        csv=False,
        links=links,
    )

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

示例13: create

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def create():
    if not session.marked_items:
        session.flash = T('You must mark some items first')
        redirect(URL('default', 'index'))

    fields = []
    # i need the input of the based item fields
    fdl_headline = db.item.headline
    fields.append(fdl_headline)
    fdl_keywords = db.item.keywords
    keywords_list = []
    for item_id in session.marked_items:
        _item = application.getItemByUUID(item_id)
        keywords_list.extend(_item.keywords)
    keywords_list = list(set(keywords_list))  # remove any dup
    fdl_keywords.default = keywords_list
    fields.append(fdl_keywords)
    fields.append(db.item.genre)
    fdl_item_type = db.item.item_type
    fdl_item_type.writable = False
    fdl_item_type.readable = False
    fdl_item_type.default = 'package'
    fields.append(db.plugin_package_content.description)

    form = SQLFORM.factory(
        *fields,
        table_name='plugin_package_item'  # to allow the correct file name
    )

    if form.process(dbio=False).accepted:
        form.vars.item_id = application.createItem('package', form.vars)
        form.vars.item_list = session.marked_items
        db.plugin_package_content.insert(
            **db.plugin_package_content._filter_fields(form.vars)
        )
        application.indexItem(form.vars.item_id)
        session.marked_items = []
        redirect(URL('default', 'index'))

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

示例14: create

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

示例15: create

# 需要导入模块: from gluon import current [as 别名]
# 或者: from gluon.current import T [as 别名]
def create():
    """
    Show the creation form of the text item.
    """

    fields = [
        db.item.headline,
        db.item.keywords,
        db.item.genre,
        db.item.item_type,
        # db.plugin_text_text.body
    ]
    db.item.item_type.default = 'text'
    db.item.item_type.writable = False
    db.item.item_type.readable = False

    form = SQLFORM.factory(*fields, submit_button=T("Next"))

    if form.process().accepted:
        item_id = application.createItem('text', form.vars)
        form.vars.item_id = item_id
        db.plugin_text_text.insert(
            **db.plugin_text_text._filter_fields(form.vars))
        application.indexItem(item_id)
        redirect(URL('index.html', args=[item_id]))

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


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