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

Python utils.create_receipt函数代码示例

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

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



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

示例1: for_user

 def for_user(self, ins, flavour, encode):
     encode.return_value = "tmp-to-keep-memoize-happy"
     create_receipt(ins.pk, flavour=flavour)
     receipt = encode.call_args[0][0]
     eq_(receipt["product"]["type"], flavour)
     eq_(receipt["verify"], absolutify(reverse("receipt.verify", args=[ins.addon.app_slug])))
     return receipt
开发者ID:dbialer,项目名称:zamboni,代码行数:7,代码来源:test_models.py


示例2: for_user

 def for_user(self, ins, flavour, encode):
     encode.return_value = 'tmp-to-keep-memoize-happy'
     create_receipt(ins.pk, flavour=flavour)
     receipt = encode.call_args[0][0]
     eq_(receipt['product']['type'], flavour)
     eq_(receipt['verify'],
         absolutify(reverse('receipt.verify', args=[ins.addon.guid])))
     return receipt
开发者ID:sandy-slin,项目名称:zamboni,代码行数:8,代码来源:test_models.py


示例3: for_user

 def for_user(self, app, user, flavour, encode):
     encode.return_value = 'tmp-to-keep-memoize-happy'
     create_receipt(app, user, 'some-uuid', flavour=flavour)
     receipt = encode.call_args[0][0]
     eq_(receipt['typ'], flavour + '-receipt')
     eq_(receipt['verify'],
         absolutify(reverse('receipt.verify', args=[app.guid])))
     return receipt
开发者ID:AALEKH,项目名称:zamboni,代码行数:8,代码来源:test_models.py


示例4: for_user

 def for_user(self, ins, flavour, encode):
     encode.return_value = 'tmp-to-keep-memoize-happy'
     create_receipt(ins.pk, flavour=flavour)
     receipt = encode.call_args[0][0]
     eq_(receipt['product']['type'], flavour)
     eq_(receipt['verify'],
         absolutify(reverse('receipt.verify', args=[self.webapp.app_slug])))
     assert receipt['exp'] > (calendar.timegm(time.gmtime()) +
                              (60 * 60 * 24) - TEST_LEEWAY)
开发者ID:icaaq,项目名称:zamboni,代码行数:9,代码来源:test_models.py


示例5: test_receipt_data

 def test_receipt_data(self, encode):
     encode.return_value = "tmp-to-keep-memoize-happy"
     ins = self.create_install(self.user, self.webapp)
     create_receipt(ins.pk)
     receipt = encode.call_args[0][0]
     eq_(receipt["product"]["url"], self.webapp.manifest_url[:-1])
     eq_(receipt["product"]["storedata"], "id=%s" % int(ins.addon.pk))
     assert receipt["exp"] > (calendar.timegm(time.gmtime()) + settings.WEBAPPS_RECEIPT_EXPIRY_SECONDS - TEST_LEEWAY)
     eq_(receipt["reissue"], self.webapp.get_purchase_url("reissue"))
开发者ID:dbialer,项目名称:zamboni,代码行数:9,代码来源:test_models.py


示例6: test_receipt_data

 def test_receipt_data(self, encode):
     encode.return_value = 'tmp-to-keep-memoize-happy'
     create_receipt(self.app, self.user, 'some-uuid')
     receipt = encode.call_args[0][0]
     eq_(receipt['product']['url'], self.app.manifest_url[:-1])
     eq_(receipt['product']['storedata'], 'id=%s' % int(self.app.pk))
     assert receipt['exp'] > (calendar.timegm(time.gmtime()) +
                              settings.WEBAPPS_RECEIPT_EXPIRY_SECONDS -
                              TEST_LEEWAY)
     eq_(receipt['reissue'], absolutify(reverse('receipt.reissue')))
开发者ID:AALEKH,项目名称:zamboni,代码行数:10,代码来源:test_models.py


示例7: test_receipt_data

 def test_receipt_data(self, encode):
     encode.return_value = 'tmp-to-keep-memoize-happy'
     ins = self.create_install(self.user, self.webapp)
     create_receipt(ins.pk)
     receipt = encode.call_args[0][0]
     eq_(receipt['product']['url'], self.webapp.manifest_url[:-1])
     eq_(receipt['product']['storedata'], 'id=%s' % int(ins.addon.pk))
     assert receipt['exp'] > (calendar.timegm(time.gmtime()) +
                              settings.WEBAPPS_RECEIPT_EXPIRY_SECONDS -
                              TEST_LEEWAY)
     eq_(receipt['reissue'], self.webapp.get_purchase_url('reissue'))
开发者ID:Sancus,项目名称:zamboni,代码行数:11,代码来源:test_models.py


示例8: test_crack_receipt

 def test_crack_receipt(self):
     # Check that we can decode our receipt and get a dictionary back.
     self.addon.update(type=amo.ADDON_WEBAPP, manifest_url='http://a.com')
     purchase = self.make_purchase()
     receipt = create_receipt(purchase.addon, purchase.user, purchase.uuid)
     result = verify.decode_receipt(receipt)
     eq_(result['typ'], u'purchase-receipt')
开发者ID:bdacode,项目名称:zamboni,代码行数:7,代码来源:test_verify.py


示例9: test_crack_receipt_new_called

 def test_crack_receipt_new_called(self, trunion_verify, settings):
     # Check that we can decode our receipt and get a dictionary back.
     self.app.update(type=amo.ADDON_WEBAPP, manifest_url='http://a.com')
     verify.decode_receipt(
         'jwt_public_key~' + create_receipt(
             self.app, self.user, str(uuid.uuid4())))
     assert trunion_verify.called
开发者ID:anushbmx,项目名称:zamboni,代码行数:7,代码来源:test_verify.py


示例10: test_crack_receipt

 def test_crack_receipt(self):
     # Check that we can decode our receipt and get a dictionary back.
     self.app.update(manifest_url="http://a.com")
     purchase = self.make_purchase()
     receipt = create_receipt(purchase.webapp, purchase.user, purchase.uuid)
     result = verify.decode_receipt(receipt)
     eq_(result["typ"], u"purchase-receipt")
开发者ID:shahbaz17,项目名称:zamboni,代码行数:7,代码来源:test_verify.py


示例11: test_expired

 def test_expired(self):
     receipt = create_receipt(self.addon, self.user, 'some-uuid')
     self.verify.return_value = {'status': 'expired'}
     res = self.client.post(self.url, data=receipt,
                            content_type='text/plain')
     eq_(res.status_code, 200)
     data = json.loads(res.content)
     ok_(data['receipt'])
     eq_(data['status'], 'expired')
开发者ID:anushbmx,项目名称:zamboni,代码行数:9,代码来源:test_views_api.py


示例12: _record

def _record(request, addon):
    logged = request.user.is_authenticated()
    premium = addon.is_premium()

    # Require login for premium.
    if not logged and premium:
        return http.HttpResponseRedirect(reverse('users.login'))

    ctx = {'addon': addon.pk}

    # Don't generate receipts if we're allowing logged-out install.
    if logged:
        is_dev = request.check_ownership(addon, require_owner=False,
                                         ignore_disabled=True, admin=False)
        is_reviewer = acl.check_reviewer(request)
        if (not addon.is_webapp() or not addon.is_public() and
            not (is_reviewer or is_dev)):
            raise http.Http404

        if (premium and
            not addon.has_purchased(request.amo_user) and
            not is_reviewer and not is_dev):
            raise PermissionDenied

        # If you are reviewer, you get a user receipt. Use the reviewer tools
        # to get a reviewer receipt. App developers still get their special
        # receipt.
        install_type = (apps.INSTALL_TYPE_DEVELOPER if is_dev
                        else apps.INSTALL_TYPE_USER)
        # Log the install.
        installed, c = Installed.objects.get_or_create(addon=addon,
            user=request.amo_user, install_type=install_type)

        # Get a suitable uuid for this receipt.
        uuid = get_uuid(addon, request.amo_user)

        error = ''
        receipt_cef.log(request, addon, 'sign', 'Receipt requested')
        try:
            receipt = create_receipt(addon, request.amo_user, uuid)
        except SigningError:
            error = _('There was a problem installing the app.')

        ctx.update(receipt=receipt, error=error)
    else:
        if not addon.is_public() or not addon.is_webapp():
            raise http.Http404

    amo.log(amo.LOG.INSTALL_ADDON, addon)
    record_action('install', request, {
        'app-domain': addon.domain_from_url(addon.origin, allow_none=True),
        'app-id': addon.pk,
        'anonymous': request.user.is_anonymous(),
    })

    return ctx
开发者ID:Dreadchild,项目名称:zamboni,代码行数:56,代码来源:views.py


示例13: install_record

def install_record(obj, request, install_type):
    # Generate or re-use an existing install record.
    installed, created = Installed.objects.get_or_create(addon=obj, user=request.user, install_type=install_type)

    log.info("Installed record %s: %s" % ("created" if created else "re-used", obj.pk))

    log.info("Creating receipt: %s" % obj.pk)
    receipt_cef.log(request._request, obj, "sign", "Receipt signing")
    uuid = get_uuid(installed.addon, installed.user)
    return create_receipt(installed.addon, installed.user, uuid)
开发者ID:gurumukhi,项目名称:zamboni,代码行数:10,代码来源:views.py


示例14: record

    def record(self, bundle, request, install_type):
        # Generate or re-use an existing install record.
        installed, created = Installed.objects.get_or_create(
            addon=bundle.obj, user=request.user.get_profile(), install_type=install_type
        )

        log.info("Installed record %s: %s" % ("created" if created else "re-used", bundle.obj.pk))

        log.info("Creating receipt: %s" % bundle.obj.pk)
        receipt_cef.log(request, bundle.obj, "sign", "Receipt signing")
        return create_receipt(installed)
开发者ID:pombredanne,项目名称:zamboni,代码行数:11,代码来源:api.py


示例15: record

    def record(self, bundle, request, install_type):
        # Generate or re-use an existing install record.
        installed, created = Installed.objects.get_or_create(
            addon=bundle.obj, user=request.user.get_profile(),
            install_type=install_type)

        log.info('Installed record %s: %s' % (
            'created' if created else 're-used',
            bundle.obj.pk))

        log.info('Creating receipt: %s' % bundle.obj.pk)
        receipt_cef.log(request, bundle.obj, 'sign', 'Receipt signing')
        return create_receipt(installed)
开发者ID:wraithan,项目名称:zamboni,代码行数:13,代码来源:api.py


示例16: record

    def record(self, bundle, request, install_type):
        # Generate or re-use an existing install record.
        installed, created = Installed.objects.safer_get_or_create(
            addon=bundle.obj, user=request.user.get_profile(),
            install_type=install_type)

        # Generate or re-use a recent receipt.
        receipt_cef.log(request, bundle.obj, 'request', 'Receipt requested')
        receipt = memoize_get('create-receipt', installed.pk)
        if receipt:
            return receipt

        receipt_cef.log(request, bundle.obj, 'sign', 'Receipt signing')
        return create_receipt(installed.pk)
开发者ID:flyun,项目名称:zamboni,代码行数:14,代码来源:api.py


示例17: install_record

def install_record(obj, request, install_type):
    # Generate or re-use an existing install record.
    installed, created = Installed.objects.get_or_create(
        addon=obj, user=request.user,
        install_type=install_type)

    log.info('Installed record %s: %s' % (
        'created' if created else 're-used',
        obj.pk))

    log.info('Creating receipt: %s' % obj.pk)
    receipt_cef.log(request._request, obj, 'sign', 'Receipt signing')
    uuid = get_uuid(installed.addon, installed.user)
    return create_receipt(installed.addon, installed.user, uuid)
开发者ID:Dreadchild,项目名称:zamboni,代码行数:14,代码来源:views.py


示例18: issue

def issue(request, addon):
    user = request.user
    review = acl.action_allowed_user(user, "Apps", "Review") if user else None
    developer = addon.has_author(user)
    if not (review or developer):
        raise PermissionDenied

    install, flavour = (
        (apps.INSTALL_TYPE_REVIEWER, "reviewer") if review else (apps.INSTALL_TYPE_DEVELOPER, "developer")
    )
    installed, c = Installed.objects.safer_get_or_create(addon=addon, user=request.user, install_type=install)

    error = ""
    receipt_cef.log(request, addon, "sign", "Receipt signing for %s" % flavour)
    receipt = None
    try:
        receipt = create_receipt(addon, user, get_uuid(addon, user), flavour=flavour)
    except SigningError:
        error = _("There was a problem installing the app.")

    return {"addon": addon.pk, "receipt": receipt, "error": error}
开发者ID:gurumukhi,项目名称:zamboni,代码行数:21,代码来源:views.py


示例19: issue

def issue(request, addon):
    user = request.amo_user
    review = acl.action_allowed_user(user, 'Apps', 'Review') if user else None
    developer = addon.has_author(user)
    if not (review or developer):
        raise PermissionDenied

    install, flavour = ((apps.INSTALL_TYPE_REVIEWER, 'reviewer') if review
                        else (apps.INSTALL_TYPE_DEVELOPER, 'developer'))
    installed, c = Installed.objects.safer_get_or_create(addon=addon,
        user=request.amo_user, install_type=install)

    error = ''
    receipt_cef.log(request, addon, 'sign', 'Receipt signing for %s' % flavour)
    receipt = None
    try:
        receipt = create_receipt(addon, user, get_uuid(addon, user),
                                 flavour=flavour)
    except SigningError:
        error = _('There was a problem installing the app.')

    return {'addon': addon.pk, 'receipt': receipt, 'error': error}
开发者ID:Dreadchild,项目名称:zamboni,代码行数:22,代码来源:views.py


示例20: test_addon_free

 def test_addon_free(self):
     for type_ in amo.ADDON_FREES:
         self.webapp.update(premium_type=amo.ADDON_FREE)
         ins = self.create_install(self.user, self.webapp)
         assert create_receipt(ins.pk)
开发者ID:sandy-slin,项目名称:zamboni,代码行数:5,代码来源:test_models.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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