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

Python utils.app_to_dict函数代码示例

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

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



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

示例1: test_can_purchase

 def test_can_purchase(self):
     self.make_premium(self.app, price='0.99')
     res = app_to_dict(self.app, region=regions.UK.id)
     res = app_to_dict(self.app, region=regions.UK.id)
     eq_(res['price'], None)
     eq_(res['price_locale'], None)
     eq_(res['payment_required'], True)
开发者ID:gonzalodelgado,项目名称:zamboni,代码行数:7,代码来源:test_utils_.py


示例2: test_can_purchase

 def test_can_purchase(self):
     self.make_premium(self.app, price='0.99')
     with self.settings(PURCHASE_ENABLED_REGIONS=[regions.UK.id]):
         res = app_to_dict(self.app, region=regions.UK.id)
     res = app_to_dict(self.app, region=regions.UK.id)
     eq_(res['price'], None)
     eq_(res['price_locale'], None)
     eq_(res['payment_required'], True)
开发者ID:at13,项目名称:zamboni,代码行数:8,代码来源:test_utils_.py


示例3: test_versions_multiple

 def test_versions_multiple(self):
     ver = Version.objects.create(addon=self.app, version='1.9')
     self.app.update(_current_version=ver, _latest_version=ver)
     res = app_to_dict(self.app)
     eq_(res['current_version'], ver.version)
     self.assertSetEqual([v.version for v in self.app.versions.all()],
                         res['versions'].keys())
开发者ID:at13,项目名称:zamboni,代码行数:7,代码来源:test_utils_.py


示例4: test_categories

 def test_categories(self):
     cat1 = Category.objects.create(type=amo.ADDON_WEBAPP, slug='cat1')
     cat2 = Category.objects.create(type=amo.ADDON_WEBAPP, slug='cat2')
     AddonCategory.objects.create(addon=self.app, category=cat1)
     AddonCategory.objects.create(addon=self.app, category=cat2)
     res = app_to_dict(self.app)
     self.assertSetEqual(res['categories'], ['cat1', 'cat2'])
开发者ID:at13,项目名称:zamboni,代码行数:7,代码来源:test_utils_.py


示例5: test_cannot_purchase

 def test_cannot_purchase(self):
     self.make_premium(self.app, price="0.99")
     with self.settings(PURCHASE_ENABLED_REGIONS=[]):
         res = app_to_dict(self.app, region=regions.UK.id)
     eq_(res["price"], None)
     eq_(res["price_locale"], None)
     eq_(res["payment_required"], True)
开发者ID:pythonchelle,项目名称:zamboni,代码行数:7,代码来源:test_utils_.py


示例6: test_with_preview

 def test_with_preview(self):
     obj = Preview.objects.create(
         **{"caption": "foo", "filetype": "image/png", "thumbtype": "image/png", "addon": self.app}
     )
     preview = app_to_dict(self.app)["previews"][0]
     self.assertSetEqual(preview, ["caption", "filetype", "id", "image_url", "thumbnail_url", "resource_uri"])
     eq_(preview["caption"], "foo")
     eq_(int(preview["id"]), obj.pk)
开发者ID:pythonchelle,项目名称:zamboni,代码行数:8,代码来源:test_utils_.py


示例7: test_missing_price

    def test_missing_price(self):
        premium = self.make_premium(self.app, price='0.99')
        premium.price = None
        premium.save()

        res = app_to_dict(self.app)
        eq_(res['price'], None)
        eq_(res['price_locale'], None)
开发者ID:at13,项目名称:zamboni,代码行数:8,代码来源:test_utils_.py


示例8: test_with_locale

    def test_with_locale(self):
        premium = self.make_premium(self.app, price="0.99")
        PriceCurrency.objects.create(region=regions.PL.id, currency="PLN", price="5.01", tier=premium.price, provider=1)

        with self.activate(locale="fr"):
            res = app_to_dict(self.app, region=regions.PL.id)
            eq_(res["price"], Decimal("5.01"))
            eq_(res["price_locale"], u"5,01\xa0PLN")
开发者ID:pythonchelle,项目名称:zamboni,代码行数:8,代码来源:test_utils_.py


示例9: dehydrate

    def dehydrate(self, bundle):
        obj = bundle.obj
        amo_user = getattr(bundle.request, "amo_user", None)
        bundle.data.update(app_to_dict(obj, region=bundle.request.REGION.id, profile=amo_user, request=bundle.request))
        bundle.data["privacy_policy"] = PrivacyPolicyResource().get_resource_uri(bundle)

        self.dehydrate_extra(bundle)
        return bundle
开发者ID:pythonchelle,项目名称:zamboni,代码行数:8,代码来源:resources.py


示例10: test_with_preview

 def test_with_preview(self):
     obj = Preview.objects.create(**{
         'filetype': 'image/png', 'thumbtype': 'image/png',
         'addon': self.app})
     preview = app_to_dict(self.app)['previews'][0]
     self.assertSetEqual(preview,
         ['filetype', 'id', 'image_url', 'thumbnail_url', 'resource_uri'])
     eq_(int(preview['id']), obj.pk)
开发者ID:gonzalodelgado,项目名称:zamboni,代码行数:8,代码来源:test_utils_.py


示例11: dehydrate

 def dehydrate(self, bundle):
     obj = bundle.obj
     amo_user = getattr(bundle.request, 'amo_user', None)
     bundle.data.update(app_to_dict(obj,
         currency=bundle.request.REGION.default_currency, profile=amo_user))
     bundle.data['privacy_policy'] = (
         PrivacyPolicyResource().get_resource_uri(bundle))
     return bundle
开发者ID:markgif,项目名称:zamboni,代码行数:8,代码来源:resources.py


示例12: test_with_locale

    def test_with_locale(self):
        premium = self.make_premium(self.app, price='0.99')
        PriceCurrency.objects.create(region=regions.PL.id, currency='PLN',
                                     price='5.01', tier=premium.price,
                                     provider=1)

        with self.activate(locale='fr'):
            res = app_to_dict(self.app, region=regions.PL.id)
            eq_(res['price'], Decimal('5.01'))
            eq_(res['price_locale'], u'5,01\xa0PLN')
开发者ID:at13,项目名称:zamboni,代码行数:10,代码来源:test_utils_.py


示例13: dehydrate

 def dehydrate(self, bundle):
     obj = bundle.obj
     user = getattr(bundle.request, 'user', None)
     bundle.data.update(app_to_dict(obj,
         currency=bundle.request.REGION.default_currency, user=user))
     bundle.data['upsell'] = False
     if obj.upsell:
         upsell_bundle = Bundle(obj=obj.upsell.premium,
                                request=bundle.request)
         bundle.data['upsell'] = self.full_dehydrate(upsell_bundle).data
     return bundle
开发者ID:jvillalobos,项目名称:zamboni,代码行数:11,代码来源:resources.py


示例14: dehydrate

    def dehydrate(self, bundle):
        obj = bundle.obj
        amo_user = getattr(bundle.request, 'amo_user', None)
        bundle.data.update(app_to_dict(obj,
            region=bundle.request.REGION.id, profile=amo_user))
        bundle.data['privacy_policy'] = (
            PrivacyPolicyResource().get_resource_uri(bundle))

        # Add extra data for reviewers. Used in reviewer tool search.
        bundle = update_with_reviewer_data(bundle)

        return bundle
开发者ID:wraithan,项目名称:zamboni,代码行数:12,代码来源:resources.py


示例15: dehydrate

    def dehydrate(self, bundle):
        obj = bundle.obj
        amo_user = getattr(bundle.request, 'amo_user', None)
        region = (bundle.request.REGION.id if hasattr(bundle.request, 'REGION')
                  else None)
        bundle.data.update(app_to_dict(obj, region=region, profile=amo_user,
                                       request=bundle.request))
        bundle.data['privacy_policy'] = (
            PrivacyPolicyResource().get_resource_uri(bundle))

        self.dehydrate_extra(bundle)
        return bundle
开发者ID:chusiang,项目名称:zamboni,代码行数:12,代码来源:resources.py


示例16: test_waffle_fallback_anon

 def test_waffle_fallback_anon(self):
     flag = waffle.models.Flag.objects.get(name='allow-paid-app-search')
     flag.everyone = True
     flag.save()
     self.make_premium(self.app, price='0.99')
     req = RequestFactory().get('/')
     req.user = AnonymousUser()
     with self.settings(PURCHASE_ENABLED_REGIONS=[]):
         res = app_to_dict(self.app, region=regions.US.id, request=req)
     eq_(res['price'], Decimal('0.99'))
     eq_(res['price_locale'], '$0.99')
     eq_(res['payment_required'], True)
开发者ID:at13,项目名称:zamboni,代码行数:12,代码来源:test_utils_.py


示例17: dehydrate

 def dehydrate(self, bundle):
     obj = bundle.obj
     amo_user = getattr(bundle.request, 'amo_user', None)
     bundle.data.update(app_to_dict(obj,
         currency=bundle.request.REGION.default_currency, profile=amo_user))
     bundle.data['upsell'] = False
     bundle.data['privacy_policy'] = PrivacyPolicyResource().get_resource_uri(bundle)
     if obj.upsell:
         upsell_bundle = Bundle(obj=obj.upsell.premium,
                                request=bundle.request)
         bundle.data['upsell'] = self.full_dehydrate(upsell_bundle).data
     return bundle
开发者ID:mitramichaeljade,项目名称:zamboni,代码行数:12,代码来源:resources.py


示例18: dehydrate

 def dehydrate(self, bundle):
     obj = bundle.obj
     user = getattr(bundle.request, 'user', None)
     bundle.data.update(app_to_dict(obj, user=user))
     bundle.data['upsell'] = False
     if obj.upsell:
         upsell_bundle = Bundle(obj=obj.upsell.premium,
                                request=bundle.request)
         bundle.data['upsell'] = self.full_dehydrate(upsell_bundle).data
     if not obj.has_price():
         bundle.data['price'] = None
     return bundle
开发者ID:flyun,项目名称:zamboni,代码行数:12,代码来源:resources.py


示例19: test_waffle_fallback

    def test_waffle_fallback(self):
        self.make_premium(self.app, price="0.99")
        flag = waffle.models.Flag.objects.get(name="allow-paid-app-search")
        flag.everyone = None
        flag.users.add(self.profile.user)
        flag.save()

        req = RequestFactory().get("/")
        req.user = self.profile.user
        with self.settings(PURCHASE_ENABLED_REGIONS=[]):
            res = app_to_dict(self.app, region=regions.US.id, request=req)
        eq_(res["price"], Decimal("0.99"))
        eq_(res["price_locale"], "$0.99")
        eq_(res["payment_required"], True)
开发者ID:pythonchelle,项目名称:zamboni,代码行数:14,代码来源:test_utils_.py


示例20: test_waffle_fallback

    def test_waffle_fallback(self):
        self.make_premium(self.app, price='0.99')
        flag = waffle.models.Flag.objects.get(name='override-app-purchase')
        flag.everyone = None
        flag.users.add(self.profile.user)
        flag.save()

        req = RequestFactory().get('/')
        req.user = self.profile.user
        with self.settings(PURCHASE_LIMITED=True):
            res = app_to_dict(self.app, region=regions.US.id, request=req)
        eq_(res['price'], Decimal('0.99'))
        eq_(res['price_locale'], '$0.99')
        eq_(res['payment_required'], True)
开发者ID:gonzalodelgado,项目名称:zamboni,代码行数:14,代码来源:test_utils_.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python utils.es_app_to_dict函数代码示例发布时间:2022-05-27
下一篇:
Python pre_generate_apk.delay函数代码示例发布时间: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