• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python helpers.product_as_dict函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mkt.site.helpers.product_as_dict函数的典型用法代码示例。如果您正苦于以下问题:Python product_as_dict函数的具体用法?Python product_as_dict怎么用?Python product_as_dict使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: get_apps

    def get_apps(self):
        ids = []
        my_apps = cache.get(self.key)
        if my_apps:
            for id in my_apps.split(","):
                valid = cache.get("%s:review_viewing:%s" % (settings.CACHE_PREFIX, id))
                if valid and valid == self.user_id:
                    ids.append(id)

        apps = []
        for app in Webapp.objects.filter(id__in=ids):
            apps.append(
                {
                    "app": app,
                    "app_attrs": json.dumps(product_as_dict(self.request, app, False, "reviewer"), cls=JSONEncoder),
                }
            )
        return apps
开发者ID:TwinkleChawla,项目名称:zamboni,代码行数:18,代码来源:utils.py


示例2: test_correct

    def test_correct(self):
        request = mock.Mock(GET={"src": "poop"})
        app = Webapp.objects.get(id=337141)

        data = product_as_dict(request, app)
        eq_(data["src"], "poop")
        eq_(data["is_packaged"], False)
        eq_(data["categories"], [])
        eq_(data["name"], "Something Something Steamcube!")
        eq_(data["id"], "337141")
        eq_(data["manifest_url"], "http://micropipes.com/temp/steamcube.webapp")

        tokenUrl = "/reviewers/app/something-something/token"
        recordUrl = "/app/something-something/purchase/record?src=poop"
        assert tokenUrl in data["tokenUrl"], "Invalid Token URL. Expected %s; Got %s" % (tokenUrl, data["tokenUrl"])
        assert recordUrl in data["recordUrl"], "Invalid Record URL. Expected %s; Got %s" % (
            recordUrl,
            data["recordUrl"],
        )
开发者ID:kolyaflash,项目名称:zamboni,代码行数:19,代码来源:test_helpers.py


示例3: test_correct

    def test_correct(self):
        request = mock.Mock(GET={'src': 'poop'})
        app = Webapp.objects.get(id=337141)

        data = product_as_dict(request, app)
        eq_(data['src'], 'poop')
        eq_(data['is_packaged'], False)
        eq_(data['categories'], [])
        eq_(data['name'], 'Something Something Steamcube!')
        eq_(data['id'], '337141')
        eq_(data['manifest_url'], 'http://micropipes.com/temp/steamcube.webapp')

        tokenUrl = '/reviewers/app/something-something/token'
        recordUrl = '/app/something-something/purchase/record?src=poop'
        assert tokenUrl in data['tokenUrl'], (
            'Invalid Token URL. Expected %s; Got %s'
            % (tokenUrl, data['tokenUrl']))
        assert recordUrl in data['recordUrl'], (
            'Invalid Record URL. Expected %s; Got %s'
            % (recordUrl, data['recordUrl']))
开发者ID:MorrisJobke,项目名称:zamboni,代码行数:20,代码来源:test_helpers.py


示例4: apps_reviewing

def apps_reviewing(request):
    ids = []
    key = '%s:myapps:%s' % (settings.CACHE_PREFIX, request.amo_user.id)
    my_apps = cache.get(key)
    if my_apps:
        for id in my_apps.split(','):
            valid = cache.get('%s:review_viewing:%s' % (settings.CACHE_PREFIX,
                                                        id))
            if valid and valid == request.amo_user.id:
                ids.append(id)

    apps = []
    for app in Webapp.objects.filter(id__in=ids):
        apps.append({
            'app': app,
            'app_attrs': json.dumps(
                product_as_dict(request, app, False, 'reviewer'),
                cls=JSONEncoder),
        })

    return jingo.render(request, 'reviewers/apps_reviewing.html', context(**{
        'apps': apps}))
开发者ID:fwenzel,项目名称:zamboni,代码行数:22,代码来源:views.py


示例5: _review


#.........这里部分代码省略.........
            if old_features != new_features:
                # The reviewer overrode the requirements. We need to not
                # publish this app immediately.
                if addon.make_public == amo.PUBLIC_IMMEDIATELY:
                    addon.update(make_public=amo.PUBLIC_WAIT)

                appfeatures_form.save(mark_for_rereview=False)

                # Log that the reviewer changed the minimum requirements.
                added_features = new_features - old_features
                removed_features = old_features - new_features

                fmt = ', '.join(
                      [_(u'Added {0}').format(f) for f in added_features] +
                      [_(u'Removed {0}').format(f) for f in removed_features])
                # L10n: {0} is the list of requirements changes.
                msg = _(u'Requirements changed by reviewer: {0}').format(fmt)
                amo.log(amo.LOG.REVIEW_FEATURES_OVERRIDE, addon,
                        addon.current_version, details={'comments': msg})

        score = form.helper.process()

        if form.cleaned_data.get('notify'):
            # TODO: bug 741679 for implementing notifications in Marketplace.
            EditorSubscription.objects.get_or_create(user=request.amo_user,
                                                     addon=addon)

        is_tarako = form.cleaned_data.get('is_tarako', False)
        if is_tarako:
            Tag(tag_text='tarako').save_tag(addon)
        else:
            Tag(tag_text='tarako').remove_tag(addon)

        # Success message.
        if score:
            score = ReviewerScore.objects.filter(user=request.amo_user)[0]
            # L10N: {0} is the type of review. {1} is the points they earned.
            #       {2} is the points they now have total.
            success = _(
               u'"{0}" successfully processed (+{1} points, {2} total).'
                .format(unicode(amo.REVIEWED_CHOICES[score.note_key]),
                        score.score,
                        ReviewerScore.get_total(request.amo_user)))
        else:
            success = _('Review successfully processed.')
        messages.success(request, success)

        return redirect(redirect_url)

    canned = CannedResponse.objects.all()
    actions = form.helper.actions.items()

    try:
        if not version:
            raise Version.DoesNotExist
        show_diff = (addon.versions.exclude(id=version.id)
                                   .filter(files__isnull=False,
                                           created__lt=version.created,
                                           files__status=amo.STATUS_PUBLIC)
                                   .latest())
    except Version.DoesNotExist:
        show_diff = None

    # The actions we should show a minimal form from.
    actions_minimal = [k for (k, a) in actions if not a.get('minimal')]

    # We only allow the user to check/uncheck files for "pending"
    allow_unchecking_files = form.helper.review_type == "pending"

    versions = (Version.with_deleted.filter(addon=addon)
                                    .order_by('-created')
                                    .transform(Version.transformer_activity)
                                    .transform(Version.transformer))

    product_attrs = {
        'product': json.dumps(
            product_as_dict(request, addon, False, 'reviewer'),
            cls=JSONEncoder),
        'manifest_url': addon.manifest_url,
    }

    pager = paginate(request, versions, 10)

    num_pages = pager.paginator.num_pages
    count = pager.paginator.count

    ctx = context(request, version=version, product=addon, pager=pager,
                  num_pages=num_pages, count=count,
                  form=form, canned=canned, is_admin=is_admin,
                  status_types=amo.MKT_STATUS_CHOICES, show_diff=show_diff,
                  allow_unchecking_files=allow_unchecking_files,
                  actions=actions, actions_minimal=actions_minimal,
                  tab=queue_type, product_attrs=product_attrs,
                  attachment_formset=attachment_formset,
                  appfeatures_form=appfeatures_form)

    if features_list is not None:
        ctx['feature_list'] = features_list

    return render(request, 'reviewers/review.html', ctx)
开发者ID:petercpg,项目名称:zamboni,代码行数:101,代码来源:views.py


示例6: _review


#.........这里部分代码省略.........
                msg = _(u"Device(s) changed by " "reviewer: {0}").format(
                    ", ".join(
                        [_(u"Added {0}").format(unicode(amo.DEVICE_TYPES[d].name)) for d in added_devices]
                        + [_(u"Removed {0}").format(unicode(amo.DEVICE_TYPES[d].name)) for d in removed_devices]
                    )
                )
                amo.log(amo.LOG.REVIEW_DEVICE_OVERRIDE, addon, addon.current_version, details={"comments": msg})

            if waffle.switch_is_active("buchets") and old_features != new_features:
                # The reviewer overrode the requirements. We need to not
                # publish this app immediately.
                if addon.make_public == amo.PUBLIC_IMMEDIATELY:
                    addon.update(make_public=amo.PUBLIC_WAIT)

                appfeatures_form.save(mark_for_rereview=False)

                # Log that the reviewer changed the minimum requirements.
                added_features = new_features - old_features
                removed_features = old_features - new_features

                fmt = ", ".join(
                    [_(u"Added {0}").format(f) for f in added_features]
                    + [_(u"Removed {0}").format(f) for f in removed_features]
                )
                # L10n: {0} is the list of requirements changes.
                msg = _(u"Requirements changed by reviewer: {0}").format(fmt)
                amo.log(amo.LOG.REVIEW_FEATURES_OVERRIDE, addon, addon.current_version, details={"comments": msg})

        form.helper.process()

        if form.cleaned_data.get("notify"):
            EditorSubscription.objects.get_or_create(user=request.amo_user, addon=addon)

        messages.success(request, _("Review successfully processed."))
        return redirect(redirect_url)

    canned = AppCannedResponse.objects.all()
    actions = form.helper.actions.items()

    try:
        if not version:
            raise Version.DoesNotExist
        show_diff = (
            addon.versions.exclude(id=version.id)
            .filter(files__isnull=False, created__lt=version.created, files__status=amo.STATUS_PUBLIC)
            .latest()
        )
    except Version.DoesNotExist:
        show_diff = None

    # The actions we should show a minimal form from.
    actions_minimal = [k for (k, a) in actions if not a.get("minimal")]

    # We only allow the user to check/uncheck files for "pending"
    allow_unchecking_files = form.helper.review_type == "pending"

    versions = (
        Version.with_deleted.filter(addon=addon)
        .order_by("-created")
        .transform(Version.transformer_activity)
        .transform(Version.transformer)
    )

    product_attrs = {
        "product": json.dumps(product_as_dict(request, addon, False, "reviewer"), cls=JSONEncoder),
        "manifest_url": addon.manifest_url,
    }

    pager = paginate(request, versions, 10)

    num_pages = pager.paginator.num_pages
    count = pager.paginator.count

    ctx = context(
        request,
        version=version,
        product=addon,
        pager=pager,
        num_pages=num_pages,
        count=count,
        flags=Review.objects.filter(addon=addon, flag=True),
        form=form,
        canned=canned,
        is_admin=is_admin,
        status_types=amo.STATUS_CHOICES,
        show_diff=show_diff,
        allow_unchecking_files=allow_unchecking_files,
        actions=actions,
        actions_minimal=actions_minimal,
        tab=queue_type,
        product_attrs=product_attrs,
        attachment_formset=attachment_formset,
        appfeatures_form=appfeatures_form,
        default_visibility=DEFAULT_ACTION_VISIBILITY,
    )

    if features_list is not None:
        ctx["feature_list"] = features_list

    return jingo.render(request, "reviewers/review.html", ctx)
开发者ID:steekid,项目名称:zamboni,代码行数:101,代码来源:views.py


示例7: _review

def _review(request, addon):
    version = addon.latest_version

    if not settings.ALLOW_SELF_REVIEWS and addon.has_author(request.amo_user):
        messages.warning(request, _('Self-reviews are not allowed.'))
        return redirect(reverse('reviewers.home'))

    if (addon.status == amo.STATUS_BLOCKED and
        not acl.action_allowed(request, 'Apps', 'ReviewEscalated')):
        messages.warning(
            request, _('Only senior reviewers can review blocklisted apps.'))
        return redirect(reverse('reviewers.home'))

    form = forms.get_review_form(request.POST or None, request=request,
                                 addon=addon, version=version)
    queue_type = form.helper.review_type
    redirect_url = reverse('reviewers.apps.queue_%s' % queue_type)
    is_admin = acl.action_allowed(request, 'Addons', 'Edit')

    if request.method == 'POST' and form.is_valid():

        old_types = set(o.id for o in addon.device_types)
        new_types = set(form.cleaned_data.get('device_override'))

        if (form.cleaned_data.get('action') == 'public' and
            old_types != new_types):

            # The reviewer overrode the device types. We need to not publish
            # this app immediately.
            if addon.make_public == amo.PUBLIC_IMMEDIATELY:
                addon.update(make_public=amo.PUBLIC_WAIT)

            # And update the device types to what the reviewer set.
            AddonDeviceType.objects.filter(addon=addon).delete()
            for device in form.cleaned_data.get('device_override'):
                addon.addondevicetype_set.create(device_type=device)

            # Log that the reviewer changed the device types.
            added_devices = new_types - old_types
            removed_devices = old_types - new_types
            msg = _(u'Device(s) changed by reviewer: {0}').format(', '.join(
                [_(u'Added {0}').format(unicode(amo.DEVICE_TYPES[d].name))
                 for d in added_devices] +
                [_(u'Removed {0}').format(unicode(amo.DEVICE_TYPES[d].name))
                 for d in removed_devices]))
            amo.log(amo.LOG.REVIEW_DEVICE_OVERRIDE, addon,
                    addon.current_version, details={'comments': msg})

        form.helper.process()

        if form.cleaned_data.get('notify'):
            EditorSubscription.objects.get_or_create(user=request.amo_user,
                                                     addon=addon)

        messages.success(request, _('Review successfully processed.'))
        return redirect(redirect_url)

    canned = AppCannedResponse.objects.all()
    actions = form.helper.actions.items()

    try:
        show_diff = (addon.versions.exclude(id=version.id)
                                   .filter(files__isnull=False,
                                           created__lt=version.created,
                                           files__status=amo.STATUS_PUBLIC)
                                   .latest())
    except Version.DoesNotExist:
        show_diff = None

    # The actions we should show a minimal form from.
    actions_minimal = [k for (k, a) in actions if not a.get('minimal')]

    # We only allow the user to check/uncheck files for "pending"
    allow_unchecking_files = form.helper.review_type == "pending"

    versions = (Version.objects.filter(addon=addon)
                               .order_by('-created')
                               .transform(Version.transformer_activity)
                               .transform(Version.transformer))

    product_attrs = {
        'product': json.dumps(
            product_as_dict(request, addon, False, 'reviewer'),
            cls=JSONEncoder),
        'manifest_url': addon.manifest_url,
    }

    pager = paginate(request, versions, 10)

    num_pages = pager.paginator.num_pages
    count = pager.paginator.count

    ctx = context(version=version, product=addon, pager=pager,
                  num_pages=num_pages, count=count,
                  flags=Review.objects.filter(addon=addon, flag=True),
                  form=form, canned=canned, is_admin=is_admin,
                  status_types=amo.STATUS_CHOICES, show_diff=show_diff,
                  allow_unchecking_files=allow_unchecking_files,
                  actions=actions, actions_minimal=actions_minimal,
                  tab=queue_type, product_attrs=product_attrs)
#.........这里部分代码省略.........
开发者ID:bearstech,项目名称:zamboni,代码行数:101,代码来源:views.py


示例8: _review


#.........这里部分代码省略.........
                    addon.update(publish_type=mkt.PUBLISH_PRIVATE)

                appfeatures_form.save(mark_for_rereview=False)

                # Log that the reviewer changed the minimum requirements.
                added_features, removed_features = (appfeatures_form
                                                    .get_changed_features())

                fmt = ', '.join(
                      [_(u'Added {0}').format(f) for f in added_features] +
                      [_(u'Removed {0}').format(f) for f in removed_features])
                # L10n: {0} is the list of requirements changes.
                msg = _(u'Requirements changed by reviewer: {0}').format(fmt)

                log_reviewer_action(addon, request.user, msg,
                                    mkt.LOG.REVIEW_FEATURES_OVERRIDE)

        score = form.helper.process()

        if form.cleaned_data.get('is_showcase'):
            if not addon.tags.filter(tag_text=SHOWCASE_TAG).exists():
                Tag(tag_text=SHOWCASE_TAG).save_tag(addon)
                recipient_list = (settings.APP_CURATION_BOARD_EMAIL,)
                subject = u'App [%s] nominated to be featured' % addon.name
                msg = (u'The Marketplace reviewer %s thinks %s (%s%s) is'
                       u'good enough to be a featured app.\n\n' % (
                           request.user, addon.name, settings.SITE_URL,
                           addon.get_url_path()))
                send_mail(subject, msg, recipient_list=recipient_list)
        else:
            Tag(tag_text=SHOWCASE_TAG).remove_tag(addon)

        # Success message.
        if score:
            score = ReviewerScore.objects.filter(user=request.user)[0]
            # L10N: {0} is the type of review. {1} is the points they earned.
            #       {2} is the points they now have total.
            success = _(
                u'"{0}" successfully processed (+{1} points, {2} total).'
                .format(unicode(mkt.REVIEWED_CHOICES[score.note_key]),
                        score.score,
                        ReviewerScore.get_total(request.user)))
        else:
            success = _('Review successfully processed.')
        messages.success(request, success)

        return redirect(redirect_url)

    canned = CannedResponse.objects.all()
    actions = form.helper.actions.items()

    try:
        if not version:
            raise Version.DoesNotExist
        show_diff = (addon.versions.exclude(id=version.id)
                                   .filter(files__isnull=False,
                                           created__lt=version.created,
                                           files__status=mkt.STATUS_PUBLIC)
                                   .latest())
    except Version.DoesNotExist:
        show_diff = None

    # The actions we should show a minimal form from.
    actions_minimal = [k for (k, a) in actions if not a.get('minimal')]

    # We only allow the user to check/uncheck files for "pending"
    allow_unchecking_files = form.helper.review_type == "pending"

    versions = (Version.with_deleted.filter(addon=addon)
                                    .order_by('-created')
                                    .transform(Version.transformer_activity)
                                    .transform(Version.transformer))

    product_attrs = {
        'product': json.dumps(
            product_as_dict(request, addon, False, 'reviewer'),
            cls=JSONEncoder),
        'manifest_url': addon.manifest_url,
    }

    pager = paginate(request, versions, 10)

    num_pages = pager.paginator.num_pages
    count = pager.paginator.count

    ctx = context(request, version=version, product=addon, pager=pager,
                  num_pages=num_pages, count=count,
                  form=form, canned=canned, is_admin=is_admin,
                  status_types=mkt.STATUS_CHOICES, show_diff=show_diff,
                  allow_unchecking_files=allow_unchecking_files,
                  actions=actions, actions_minimal=actions_minimal,
                  tab=queue_type, product_attrs=product_attrs,
                  attachment_formset=attachment_formset,
                  appfeatures_form=appfeatures_form,
                  testedon_formset=testedon_formset)

    if features_list is not None:
        ctx['feature_list'] = features_list

    return render(request, 'reviewers/review.html', ctx)
开发者ID:carriercomm,项目名称:zamboni,代码行数:101,代码来源:views.py


示例9: _review

def _review(request, addon):
    version = addon.latest_version

    if (not settings.DEBUG and
        addon.authors.filter(user=request.user).exists()):
        messages.warning(request, _('Self-reviews are not allowed.'))
        return redirect(reverse('reviewers.home'))

    form = forms.get_review_form(request.POST or None, request=request,
                                 addon=addon, version=version)
    queue_type = form.helper.review_type
    redirect_url = reverse('reviewers.apps.queue_%s' % queue_type)
    is_admin = acl.action_allowed(request, 'Addons', 'Edit')

    if request.method == 'POST' and form.is_valid():
        form.helper.process()
        if form.cleaned_data.get('notify'):
            EditorSubscription.objects.get_or_create(user=request.amo_user,
                                                     addon=addon)
        if form.cleaned_data.get('adminflag') and is_admin:
            addon.update(admin_review=False)
        messages.success(request, _('Review successfully processed.'))
        return redirect(redirect_url)

    canned = AppCannedResponse.objects.all()
    actions = form.helper.actions.items()

    statuses = [amo.STATUS_PUBLIC, amo.STATUS_LITE,
                amo.STATUS_LITE_AND_NOMINATED]

    try:
        show_diff = (addon.versions.exclude(id=version.id)
                                   .filter(files__isnull=False,
                                       created__lt=version.created,
                                       files__status__in=statuses)
                                   .latest())
    except Version.DoesNotExist:
        show_diff = None

    # The actions we should show a minimal form from.
    actions_minimal = [k for (k, a) in actions if not a.get('minimal')]

    # We only allow the user to check/uncheck files for "pending"
    allow_unchecking_files = form.helper.review_type == "pending"

    versions = (Version.objects.filter(addon=addon)
                               .exclude(files__status=amo.STATUS_BETA)
                               .order_by('-created')
                               .transform(Version.transformer_activity)
                               .transform(Version.transformer))

    product_attrs = {
        'product': json.dumps(
            product_as_dict(request, addon, False, 'developer'),
            cls=JSONEncoder),
        'manifestUrl': addon.manifest_url,
    }

    pager = paginate(request, versions, 10)

    num_pages = pager.paginator.num_pages
    count = pager.paginator.count

    ctx = context(version=version, product=addon, pager=pager,
                  num_pages=num_pages, count=count,
                  flags=Review.objects.filter(addon=addon, flag=True),
                  form=form, canned=canned, is_admin=is_admin,
                  status_types=amo.STATUS_CHOICES, show_diff=show_diff,
                  allow_unchecking_files=allow_unchecking_files,
                  actions=actions, actions_minimal=actions_minimal,
                  tab=queue_type, product_attrs=product_attrs)

    return jingo.render(request, 'reviewers/review.html', ctx)
开发者ID:Sancus,项目名称:zamboni,代码行数:73,代码来源:views.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python mail.send_mail函数代码示例发布时间:2022-05-27
下一篇:
Python helpers.market_tile函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap