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


Python Content.get_child_nb方法代码示例

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


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

示例1: serialize_content_for_workspace_and_folder

# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_child_nb [as 别名]
def serialize_content_for_workspace_and_folder(content: Content, context: Context):
    thread_nb_all  = content.get_child_nb(ContentType.Thread)
    thread_nb_open = content.get_child_nb(ContentType.Thread)
    file_nb_all  = content.get_child_nb(ContentType.File)
    file_nb_open = content.get_child_nb(ContentType.File)
    folder_nb_all  = content.get_child_nb(ContentType.Folder)
    folder_nb_open = content.get_child_nb(ContentType.Folder)
    page_nb_all  = content.get_child_nb(ContentType.Page)
    page_nb_open = content.get_child_nb(ContentType.Page)

    content_nb_all = thread_nb_all +\
                     thread_nb_open +\
                     file_nb_all +\
                     file_nb_open +\
                     folder_nb_all +\
                     folder_nb_open +\
                     page_nb_all +\
                     page_nb_open


    result = None
    if content.type==ContentType.Folder:
        allowed_content = DictLikeClass(content.properties['allowed_content']),

        result = DictLikeClass(
            id=content.content_id,
            label=content.label,
            created=content.created,
            workspace=context.toDict(content.workspace),
            allowed_content=DictLikeClass(content.properties['allowed_content']),
            allowed_content_types=context.toDict(content.get_allowed_content_types()),
            selected_revision='latest',
            status=context.toDict(content.get_status()),
            owner=context.toDict(content.owner),
            thread_nb=DictLikeClass(all=thread_nb_all,
                                    open=thread_nb_open),
            file_nb=DictLikeClass(all=file_nb_all,
                                  open=file_nb_open),
            folder_nb=DictLikeClass(all=folder_nb_all,
                                    open=folder_nb_open),
            page_nb=DictLikeClass(all=page_nb_all,
                                  open=page_nb_open),
            content_nb=DictLikeClass(all = content_nb_all)
        )

    elif content.type==ContentType.Page:
        result = DictLikeClass(
            id = content.content_id,
            label = content.label,
            created = content.created,
            workspace = context.toDict(content.workspace),
            owner = DictLikeClass(
                id = content.owner.user_id,
                name = content.owner.get_display_name()
            ),
            status = DictLikeClass(id='', label=''), #FIXME - EXPORT DATA
        )

    return result
开发者ID:DarkDare,项目名称:tracim,代码行数:61,代码来源:serializers.py

示例2: serialize_content_for_workspace

# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_child_nb [as 别名]
def serialize_content_for_workspace(content: Content, context: Context):
    thread_nb_all  = content.get_child_nb(ContentType.Thread)
    thread_nb_open = content.get_child_nb(ContentType.Thread)
    file_nb_all  = content.get_child_nb(ContentType.File)
    file_nb_open = content.get_child_nb(ContentType.File)
    folder_nb_all  = content.get_child_nb(ContentType.Folder)
    folder_nb_open = content.get_child_nb(ContentType.Folder)
    page_nb_all  = content.get_child_nb(ContentType.Page)
    page_nb_open = content.get_child_nb(ContentType.Page)

    content_nb_all = thread_nb_all +\
                     thread_nb_open +\
                     file_nb_all +\
                     file_nb_open +\
                     folder_nb_all +\
                     folder_nb_open +\
                     page_nb_all +\
                     page_nb_open


    result = None
    if content.type==ContentType.Folder:
        result = DictLikeClass(
            id = content.content_id,
            label = content.label,
            thread_nb = DictLikeClass(
                all = thread_nb_all,
                open = thread_nb_open,
            ),
            file_nb = DictLikeClass(
                all = file_nb_all,
                open = file_nb_open,
            ),
            folder_nb = DictLikeClass(
                all = folder_nb_all,
                open = folder_nb_open,
            ),
            page_nb = DictLikeClass(
                all = page_nb_all,
                open = page_nb_open,
            ),
            content_nb = DictLikeClass(all = content_nb_all)
        )

    return result
开发者ID:DarkDare,项目名称:tracim,代码行数:47,代码来源:serializers.py

示例3: serialize_content_for_menu_api

# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_child_nb [as 别名]
def serialize_content_for_menu_api(content: Content, context: Context):
    content_id = content.content_id
    workspace_id = content.workspace_id

    has_children = False
    if content.type == ContentType.Folder:
        has_children = content.get_child_nb(ContentType.Any) > 0

    result = DictLikeClass(
        id = CST.TREEVIEW_MENU.ID_TEMPLATE__FULL.format(workspace_id, content_id),
        children = has_children,
        text = content.get_label(),
        a_attr = { 'href' : context.url(ContentType.fill_url(content))},
        li_attr = { 'title': content.get_label(), 'class': 'tracim-tree-item-is-a-folder' },
        type = content.type,
        state = { 'opened': True if ContentType.Folder!=content.type else False, 'selected': False }
    )
    return result
开发者ID:DarkDare,项目名称:tracim,代码行数:20,代码来源:serializers.py

示例4: serialize_content_for_folder_content_list

# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_child_nb [as 别名]
def serialize_content_for_folder_content_list(content: Content, context: Context):
    content_type = ContentType(content.type)

    last_activity_date = content.get_last_activity_date()
    last_activity_date_formatted = format_datetime(last_activity_date,
                                                   locale=tg.i18n.get_lang()[0])
    last_activity_label = format_timedelta(datetime.now() - last_activity_date,
                                           locale=tg.i18n.get_lang()[0])
    last_activity_label = last_activity_label.replace(' ', '\u00A0') # espace insécable


    item = None
    if ContentType.Thread == content.type:
        item = Context(CTX.THREADS).toDict(content)
        item.type = context.toDict(content_type)
        item.folder = DictLikeClass({'id': content.parent_id}) if content.parent else None
        item.workspace = DictLikeClass({'id': content.workspace.workspace_id}) if content.workspace else None
        item.last_activity = DictLikeClass({'date': last_activity_date,
                                            'label': last_activity_date_formatted,
                                            'delta': last_activity_label})

        comments = content.get_comments()
        if len(comments)>1:
            item.notes = _('{nb} messages').format(nb=len(comments))
        else:
            item.notes = _('1 message')

    elif ContentType.File == content.type:
        item = Context(CTX.CONTENT_LIST).toDict(content)
        if len(content.revisions)>1:
            item.notes = _('{nb} revisions').format(nb=len(content.revisions))
        else:
            item.notes = _('1 revision')

    elif ContentType.Folder == content.type:
        item = Context(CTX.CONTENT_LIST).toDict(content)
        item.notes = ''

        folder_nb = content.get_child_nb(ContentType.Folder)
        if folder_nb == 1:
            item.notes += _('1 subfolder<br/>\n')
        elif folder_nb > 1:
            item.notes += _('{} subfolders<br/>').format(folder_nb)

        file_nb = content.get_child_nb(ContentType.File, ContentStatus.OPEN)
        if file_nb == 1:
            item.notes += _('1 open file<br/>\n')
        elif file_nb > 1:
            item.notes += _('{} open files<br/>').format(file_nb)

        thread_nb = content.get_child_nb(ContentType.Thread, ContentStatus.OPEN)
        if thread_nb == 1:
            item.notes += _('1 open thread<br/>\n')
        elif thread_nb > 1:
            item.notes += _('{} open threads<br/>').format(thread_nb)

        page_nb = content.get_child_nb(ContentType.Page, ContentStatus.OPEN)
        if page_nb == 1:
            item.notes += _('1 open page<br/>\n')
        elif page_nb > 1:
            item.notes += _('{} open pages<br/>').format(page_nb)
    else:
        item = Context(CTX.CONTENT_LIST).toDict(content)
        item.notes = ''

    return item
开发者ID:DarkDare,项目名称:tracim,代码行数:68,代码来源:serializers.py

示例5: serialize_content_for_workspace_and_folder

# 需要导入模块: from tracim.model.data import Content [as 别名]
# 或者: from tracim.model.data.Content import get_child_nb [as 别名]
def serialize_content_for_workspace_and_folder(content: Content, context: Context):
    thread_nb_all  = content.get_child_nb(ContentType.Thread)
    thread_nb_open = content.get_child_nb(ContentType.Thread)
    ticket_nb_all  = content.get_child_nb(ContentType.Ticket)
    ticket_nb_open = content.get_child_nb(ContentType.Ticket)
    task_nb_all  = content.get_child_nb(ContentType.Task)
    task_nb_open = content.get_child_nb(ContentType.Task)
    file_nb_all  = content.get_child_nb(ContentType.File)
    file_nb_open = content.get_child_nb(ContentType.File)
    folder_nb_all  = content.get_child_nb(ContentType.Folder)
    folder_nb_open = content.get_child_nb(ContentType.Folder)
    page_nb_all  = content.get_child_nb(ContentType.Page)
    page_nb_open = content.get_child_nb(ContentType.Page)

    content_nb_all = thread_nb_all +\
                     thread_nb_open +\
                     file_nb_all +\
                     file_nb_open +\
                     folder_nb_all +\
                     folder_nb_open +\
                     page_nb_all +\
                     page_nb_open


    result = None
    if content.type==ContentType.Folder:
        allowed_content = DictLikeClass(content.properties['allowed_content']),

        result = DictLikeClass(
            id=content.content_id,
            label=content.label,
            created=content.created,
            updated=content.last_revision.updated,
            last_modification_author=context.toDict(content.last_revision.owner),
            revision_nb=len(content.revisions),
            workspace=context.toDict(content.workspace),
            allowed_content=DictLikeClass(content.properties['allowed_content']),
            allowed_content_types=context.toDict(content.get_allowed_content_types()),
            selected_revision='latest',
            status=context.toDict(content.get_status()),
            owner=context.toDict(content.owner),
            thread_nb=DictLikeClass(all=thread_nb_all,
                                    open=thread_nb_open),
            file_nb=DictLikeClass(all=file_nb_all,
                                  open=file_nb_open),
            folder_nb=DictLikeClass(all=folder_nb_all,
                                    open=folder_nb_open),
            page_nb=DictLikeClass(all=page_nb_all,
                                  open=page_nb_open),
            task_nb=DictLikeClass(all=task_nb_all,
                                  open=task_nb_open),
            ticket_nb=DictLikeClass(all=ticket_nb_all,
                                  open=ticket_nb_open),
            content_nb=DictLikeClass(all = content_nb_all),
            is_archived=content.is_archived,
            is_deleted=content.is_deleted,
            is_editable=content.is_editable,
        )

    elif content.type==ContentType.Page:
        result = DictLikeClass(
            id = content.content_id,
            label = content.label,
            created = content.created,
            workspace = context.toDict(content.workspace),
            owner = DictLikeClass(
                id = content.owner.user_id,
                name = content.owner.get_display_name()
            ),
            status = DictLikeClass(id='', label=''), #FIXME - EXPORT DATA
        )

    return result
开发者ID:lebouquetin,项目名称:tracim,代码行数:75,代码来源:serializers.py


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