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


Python Version.transformer方法代码示例

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


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

示例1: transformer

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import transformer [as 别名]
    def transformer(addons):
        if not addons:
            return

        addon_dict = dict((a.id, a) for a in addons)
        personas = [a for a in addons if a.type_id == amo.ADDON_PERSONA]
        addons = [a for a in addons if a.type_id != amo.ADDON_PERSONA]

        # TODO(jbalogh): It would be awesome to get the versions in one
        # (or a few) queries, but we'll accept the overhead here to roll up
        # some version queries.
        versions = filter(None, (a.current_version for a in addons))
        Version.transformer(versions)

        # Attach listed authors.
        q = (UserProfile.objects.no_cache()
             .filter(addons__in=addons, addonuser__listed=True)
             .extra(select={'addon_id': 'addons_users.addon_id'})
             .order_by('addon_id', 'addonuser__position'))
        for addon_id, users in itertools.groupby(q, key=lambda u: u.addon_id):
            addon_dict[addon_id].listed_authors = list(users)

        for persona in Persona.objects.no_cache().filter(addon__in=personas):
            addon_dict[persona.addon_id].persona = persona
            addon_dict[persona.addon_id].listed_authors = []

        # Personas need categories for the JSON dump.
        Category.transformer(personas)
开发者ID:chowse,项目名称:zamboni,代码行数:30,代码来源:models.py

示例2: version_list

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import transformer [as 别名]
def version_list(request, addon_id):
    addon = get_object_or_404(Addon.objects.valid(), pk=addon_id)
    qs = (addon.versions.filter(files__status__in=amo.VALID_STATUSES)
          .distinct().order_by('-created'))
    versions = amo.utils.paginate(request, qs, PER_PAGE)
    versions.object_list = list(versions.object_list)
    Version.transformer(versions.object_list)
    return jingo.render(request, 'versions/version_list.html',
                        {'addon': addon, 'versions': versions})
开发者ID:fligtar,项目名称:zamboni,代码行数:11,代码来源:views.py

示例3: version_list

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import transformer [as 别名]
def version_list(request, addon, template, beta=False):
    status_list = (amo.STATUS_BETA,) if beta else amo.VALID_STATUSES
    qs = (addon.versions.filter(files__status__in=status_list)
          .distinct().order_by('-created'))
    versions = amo.utils.paginate(request, qs, PER_PAGE)
    versions.object_list = list(versions.object_list)
    Version.transformer(versions.object_list)
    return render(request, template, {'addon': addon, 'beta': beta,
                                      'versions': versions})
开发者ID:ddurst,项目名称:olympia,代码行数:11,代码来源:views.py

示例4: transformer

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import transformer [as 别名]
    def transformer(addons):
        if not addons:
            return

        addon_dict = dict((a.id, a) for a in addons)
        # TODO(jbalogh): It would be awesome to get the versions in one
        # (or a few) queries, but we'll accept the overhead here to roll up
        # some version queries.
        versions = filter(None, (a.current_version for a in addons))
        Version.transformer(versions)

        # Attach listed authors.
        q = (UserProfile.objects.no_cache()
             .filter(addons__in=addons, addonuser__listed=True)
             .extra(select={'addon_id': 'addons_users.addon_id'})
             .order_by('addon_id', 'addonuser__position'))
        for addon_id, users in itertools.groupby(q, key=lambda u: u.addon_id):
            addon_dict[addon_id].listed_authors = list(users)
开发者ID:rlr,项目名称:zamboni,代码行数:20,代码来源:models.py

示例5: transformer

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import transformer [as 别名]
    def transformer(addons):
        if not addons:
            return

        addon_dict = dict((a.id, a) for a in addons)
        personas = [a for a in addons if a.type == amo.ADDON_PERSONA]
        addons = [a for a in addons if a.type != amo.ADDON_PERSONA]

        version_ids = filter(None, (a._current_version_id for a in addons))
        versions = list(Version.objects.filter(id__in=version_ids))
        Version.transformer(versions)
        for version in versions:
            addon_dict[version.addon_id]._current_version = version

        # Attach listed authors.
        q = (UserProfile.objects.no_cache()
             .filter(addons__in=addons, addonuser__listed=True)
             .extra(select={'addon_id': 'addons_users.addon_id',
                            'position': 'addons_users.position'}))
        q = sorted(q, key=lambda u: (u.addon_id, u.position))
        for addon_id, users in itertools.groupby(q, key=lambda u: u.addon_id):
            addon_dict[addon_id].listed_authors = list(users)

        for persona in Persona.objects.no_cache().filter(addon__in=personas):
            addon = addon_dict[persona.addon_id]
            addon.persona = persona
            addon.listed_authors = [PersonaAuthor(persona.display_username)]
            addon.weekly_downloads = persona.popularity

        # Personas need categories for the JSON dump.
        Category.transformer(personas)

        # Store creatured apps on the add-on.
        creatured = AddonCategory.creatured()
        for addon in addons:
            addon._creatured_apps = creatured.get(addon.id, [])

        # Attach sharing stats.
        sharing.attach_share_counts(AddonShareCountTotal, 'addon', addon_dict)
开发者ID:jsocol,项目名称:zamboni,代码行数:41,代码来源:models.py

示例6: version_list

# 需要导入模块: from versions.models import Version [as 别名]
# 或者: from versions.models.Version import transformer [as 别名]
def version_list(request, addon, template):
    qs = addon.versions.filter(files__status__in=amo.VALID_STATUSES).distinct().order_by("-created")
    versions = amo.utils.paginate(request, qs, PER_PAGE)
    versions.object_list = list(versions.object_list)
    Version.transformer(versions.object_list)
    return jingo.render(request, template, {"addon": addon, "versions": versions})
开发者ID:21echoes,项目名称:zamboni,代码行数:8,代码来源:views.py


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