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


Python VirtualFolder.get_stats_for方法代码示例

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


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

示例1: get_overview_stats

# 需要导入模块: from virtualfolder.models import VirtualFolder [as 别名]
# 或者: from virtualfolder.models.VirtualFolder import get_stats_for [as 别名]
def get_overview_stats(request, *args, **kwargs):
    stats = request.resource_obj.get_stats()

    if isinstance(request.resource_obj, Directory):
        stats['vfolders'] = VirtualFolder.get_stats_for(
            request.resource_obj.pootle_path,
            request.user.is_superuser
        )

    return JsonResponse(stats)
开发者ID:Robens,项目名称:pootle,代码行数:12,代码来源:views.py

示例2: overview

# 需要导入模块: from virtualfolder.models import VirtualFolder [as 别名]
# 或者: from virtualfolder.models.VirtualFolder import get_stats_for [as 别名]
def overview(request, translation_project, dir_path, filename=None):
    project = translation_project.project
    language = translation_project.language

    directory = request.directory
    store = request.store
    is_admin = check_permission('administrate', request)

    # TODO: cleanup and refactor, retrieve from cache
    try:
        ann_virtual_path = 'announcements/projects/' + project.code
        announcement = StaticPage.objects.live(request.user).get(
            virtual_path=ann_virtual_path,
        )
    except StaticPage.DoesNotExist:
        announcement = None

    has_announcement = announcement is not None
    has_sidebar = has_announcement
    is_sidebar_open = True
    stored_mtime = None
    new_mtime = None
    cookie_data = {}

    if SIDEBAR_COOKIE_NAME in request.COOKIES:
        json_str = unquote(request.COOKIES[SIDEBAR_COOKIE_NAME])
        cookie_data = json.loads(json_str)

        if 'isOpen' in cookie_data:
            is_sidebar_open = cookie_data['isOpen']

        if project.code in cookie_data:
            stored_mtime = cookie_data[project.code]

    if has_announcement:
        ann_mtime = dateformat.format(announcement.modified_on, 'U')
        if ann_mtime != stored_mtime:
            is_sidebar_open = True
            new_mtime = ann_mtime

    ctx = get_overview_context(request)

    # TODO improve plugin logic
    if "import_export" in settings.INSTALLED_APPS and request.user.is_authenticated():
        from import_export.views import handle_upload_form

        ctx.update(handle_upload_form(request))

        has_download = (check_permission('translate', request) or
                        check_permission('suggest', request))
        ctx.update({
            'display_download': has_download,
        })
        has_sidebar = True

    stats = request.resource_obj.get_stats()

    if store is None:
        table_fields = ['name', 'progress', 'total', 'need-translation',
                        'suggestions', 'critical', 'last-updated', 'activity']
        ctx.update({
            'table': {
                'id': 'tp',
                'fields': table_fields,
                'headings': get_table_headings(table_fields),
                'parent': get_parent(directory),
                'items': get_children(directory),
            }
        })

        vfolders = get_vfolders(directory)
        if len(vfolders) > 0:
            table_fields = ['name', 'priority', 'progress', 'total',
                            'need-translation', 'suggestions', 'critical',
                            'activity']
            ctx.update({
                'vfolders': {
                    'id': 'vfolders',
                    'fields': table_fields,
                    'headings': get_table_headings(table_fields),
                    'items': get_vfolders(directory, all_vfolders=is_admin),
                },
            })

            #FIXME: set vfolders stats in the resource, don't inject them here.
            stats['vfolders'] = VirtualFolder.get_stats_for(
                directory.pootle_path,
                all_vfolders=is_admin
            )

    ctx.update({
        'translation_project': translation_project,
        'project': project,
        'language': language,
        'stats': jsonify(stats),
        'is_admin': is_admin,

        'browser_extends': 'translation_projects/base.html',

        'announcement': announcement,
#.........这里部分代码省略.........
开发者ID:OpenSource-ECom,项目名称:pootle,代码行数:103,代码来源:views.py

示例3: overview

# 需要导入模块: from virtualfolder.models import VirtualFolder [as 别名]
# 或者: from virtualfolder.models.VirtualFolder import get_stats_for [as 别名]
def overview(request, translation_project, dir_path, filename=None):
    project = translation_project.project
    language = translation_project.language

    directory = request.directory
    store = request.store
    is_admin = check_permission('administrate', request)

    ctx, cookie_data = get_sidebar_announcements_context(request, project.code,
                                                         language.code)

    ctx.update(get_overview_context(request))

    # TODO improve plugin logic
    if "import_export" in settings.INSTALLED_APPS and request.user.is_authenticated():
        from import_export.views import handle_upload_form

        ctx.update(handle_upload_form(request))

        has_download = (check_permission('translate', request) or
                        check_permission('suggest', request))
        ctx.update({
            'display_download': has_download,
            'has_sidebar': True,
        })

    stats = request.resource_obj.get_stats()

    if store is None:
        table_fields = ['name', 'progress', 'total', 'need-translation',
                        'suggestions', 'critical', 'last-updated', 'activity']
        ctx.update({
            'table': {
                'id': 'tp',
                'fields': table_fields,
                'headings': get_table_headings(table_fields),
                'items': get_children(directory),
            }
        })

        vfolders = get_vfolders(directory, all_vfolders=is_admin)
        if len(vfolders) > 0:
            table_fields = ['name', 'priority', 'progress', 'total',
                            'need-translation', 'suggestions', 'critical',
                            'activity']
            ctx.update({
                'vfolders': {
                    'id': 'vfolders',
                    'fields': table_fields,
                    'headings': get_table_headings(table_fields),
                    'items': vfolders,
                },
            })

            #FIXME: set vfolders stats in the resource, don't inject them here.
            stats['vfolders'] = VirtualFolder.get_stats_for(
                directory.pootle_path,
                all_vfolders=is_admin
            )

    ctx.update({
        'parent': get_parent(directory if store is None else store),
        'translation_project': translation_project,
        'project': project,
        'language': language,
        'stats': jsonify(stats),
        'is_admin': is_admin,

        'browser_extends': 'translation_projects/base.html',
    })

    response = render(request, 'browser/overview.html', ctx)

    if cookie_data:
        response.set_cookie(SIDEBAR_COOKIE_NAME, cookie_data)

    return response
开发者ID:Robens,项目名称:pootle,代码行数:79,代码来源:views.py


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