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

Python helpers.absolutify函数代码示例

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

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



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

示例1: create_test_receipt

def create_test_receipt(root, status, storedata=None):
    if not storedata:
        storedata = {'id': 0}
    time_ = calendar.timegm(time.gmtime())
    detail = absolutify(reverse('receipt.test.details'))
    receipt = {
        'detail': absolutify(detail),
        'exp': time_ + (60 * 60 * 24),
        'iat': time_,
        'iss': settings.SITE_URL,
        'nbf': time_,
        'product': {
            'storedata': urlencode(storedata),
            'url': root,
        },
        'reissue': detail,
        'typ': 'test-receipt',
        'user': {
            'type': 'directed-identifier',
            'value': 'none'
        },
        'verify': absolutify(reverse('receipt.test.verify',
                                     kwargs={'status': status}))

    }
    return sign(receipt)
开发者ID:shahbaz17,项目名称:zamboni,代码行数:26,代码来源:utils.py


示例2: send_purchase_receipt

def send_purchase_receipt(contrib_id, **kw):
    """
    Sends an email to the purchaser of the app.
    """
    contrib = Contribution.objects.get(pk=contrib_id)
    with contrib.user.activate_lang():
        addon = contrib.addon
        version = addon.current_version or addon.latest_version
        # L10n: {0} is the app name.
        subject = _('Receipt for {0}').format(contrib.addon.name)
        data = {
            'app_name': addon.name,
            'developer_name': version.developer_name if version else '',
            'price': contrib.get_amount_locale(get_locale_from_lang(
                contrib.source_locale)),
            'date': jingo.helpers.datetime(contrib.created.date()),
            'purchaser_email': contrib.user.email,
            # 'purchaser_phone': '',  # TODO: See bug 894614.
            # 'purchaser_last_four': '',
            'transaction_id': contrib.uuid,
            'purchases_url': absolutify('/purchases'),
            'support_url': addon.support_url,
            'terms_of_service_url': absolutify('/terms-of-use'),
        }

        log.info('Sending email about purchase: %s' % contrib_id)
        text_template = 'purchase/receipt.ltxt'
        html_template = 'purchase/receipt.html'
        send_html_mail_jinja(subject, html_template, text_template, data,
                             recipient_list=[contrib.user.email])
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:30,代码来源:tasks.py


示例3: get_mail_context

def get_mail_context(note, user_id):
    """
    Get context data for comm emails, specifically for review action emails.
    """
    obj = note.thread.obj

    # grep: comm-content-type.
    if obj.name and obj.__class__ == Webapp:
        # We need to display the name in some language that is relevant to the
        # recipient(s) instead of using the reviewer's. addon.default_locale
        # should work.
        lang = to_language(obj.default_locale)
        with translation.override(lang):
            obj = Webapp.with_deleted.get(id=obj.id)
    elif not obj.name:
        # For deleted objects.
        obj.name = obj.app_slug if hasattr(obj, 'app_slug') else obj.slug

    if user_id:
        UserProfile.objects.get(id=user_id)

    # grep: comm-content-type.
    manage_url = ''
    obj_type = ''
    thread_url = ''
    if obj.__class__ == Webapp:
        manage_url = absolutify(obj.get_dev_url('versions'))
        obj_type = 'app'
        thread_url = absolutify(reverse('commonplace.commbadge.show_thread',
                                        args=[note.thread.id]))
    elif obj.__class__ == Extension:
        manage_url = absolutify(reverse('commonplace.content.addon_manage',
                                        args=[obj.slug]))
        # Not "Firefox OS add-on" for a/an consistency with "app".
        obj_type = 'add-on'
        if user_id:
            user = UserProfile.objects.get(id=user_id)
            if acl.action_allowed_user(user, 'ContentTools', 'AddonReview'):
                thread_url = absolutify(
                    reverse('commonplace.content.addon_review',
                            args=[obj.slug]))
            else:
                thread_url = manage_url

    return {
        'mkt': mkt,
        'comm': comm,
        'is_app': obj.__class__ == Webapp,
        'is_extension': obj.__class__ == Extension,
        'manage_url': manage_url,
        'note': note,
        'obj': obj,
        'obj_type': obj_type,
        'settings': settings,
        'thread_url': thread_url
    }
开发者ID:Witia1,项目名称:zamboni,代码行数:56,代码来源:utils_mail.py


示例4: get_product_jwt

def get_product_jwt(product, contribution):
    """
    Prepare a JWT describing the item about to be purchased when
    working with navigator.mozPay().

    See the MDN docs for details on the JWT fields:
    https://developer.mozilla.org/en-US/Marketplace/Monetization
        /In-app_payments_section/mozPay_iap
    """

    issued_at = calendar.timegm(time.gmtime())
    product_data = product.product_data(contribution)
    simulation = product.simulation()
    if not simulation and not product_data.get('public_id'):
        raise ValueError(
            'Cannot create JWT without a cached public_id for '
            'app {a}'.format(a=product.addon()))

    token_data = {
        'iss': settings.APP_PURCHASE_KEY,
        'typ': settings.APP_PURCHASE_TYP,
        'aud': settings.APP_PURCHASE_AUD,
        'iat': issued_at,
        'exp': issued_at + 3600,  # expires in 1 hour
        'request': {
            'id': product.external_id(),
            'name': unicode(product.name()),
            'defaultLocale': product.default_locale(),
            'locales': product.localized_properties(),
            'icons': product.icons(),
            'description': strip_tags(product.description()),
            'pricePoint': product.price().name,
            'productData': urlencode(product_data),
            'chargebackURL': absolutify(reverse('webpay.chargeback')),
            'postbackURL': absolutify(reverse('webpay.postback')),
        }
    }
    if simulation:
        token_data['request']['simulate'] = simulation

    token = sign_webpay_jwt(token_data)

    log.debug('Preparing webpay JWT for product {p}, contrib {c}: {t}'
              .format(p=product.id(), t=token_data, c=contribution))

    return {
        'webpayJWT': token,
        'contribStatusURL': reverse(
            'webpay-status',
            kwargs={'uuid': contribution.uuid}
        )
    }
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:52,代码来源:webpay_jwt.py


示例5: _mini_manifest

def _mini_manifest(addon, version_id, token=None):
    if not addon.is_packaged:
        raise http.Http404

    version = get_object_or_404(addon.versions, pk=version_id)
    file_ = version.all_files[0]
    manifest = addon.get_manifest_json(file_)

    package_path = absolutify(
        reverse('reviewers.signed', args=[addon.app_slug, version.id]))

    if token:
        # Generate a fresh token.
        token = Token(data={'app_id': addon.id})
        token.save()
        package_path = urlparams(package_path, token=token.token)

    data = {
        'name': manifest['name'],
        'version': version.version,
        'size': file_.size,
        'release_notes': version.releasenotes,
        'package_path': package_path,
    }
    for key in ['developer', 'icons', 'locales']:
        if key in manifest:
            data[key] = manifest[key]

    return json.dumps(data, cls=JSONEncoder)
开发者ID:carriercomm,项目名称:zamboni,代码行数:29,代码来源:views.py


示例6: test_verify

 def test_verify(self):
     url = absolutify(reverse('receipt.test.verify',
                              kwargs={'status': 'expired'}))
     receipt = create_test_receipt('http://foo', 'expired')
     req = RawRequestFactory().post(url, receipt)
     res = devhub_verify(req, 'expired')
     eq_(json.loads(res.content)['status'], 'expired')
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:7,代码来源:test_views.py


示例7: get_mail_context

def get_mail_context(note):
    """
    Get context data for comm emails, specifically for review action emails.
    """
    app = note.thread.webapp

    if app.name and app.name.locale != app.default_locale:
        # We need to display the name in some language that is relevant to the
        # recipient(s) instead of using the reviewer's. webapp.default_locale
        # should work.
        lang = to_language(app.default_locale)
        with translation.override(lang):
            app = Webapp.with_deleted.get(id=app.id)
    elif not app.name:
        # For deleted apps.
        app.name = app.app_slug

    return {
        'mkt': mkt,
        'app': app,
        'comm': comm,
        'note': note,
        'review_url': absolutify(reverse('reviewers.apps.review',
                                 args=[app.app_slug])),
        'settings': settings
    }
开发者ID:shahbaz17,项目名称:zamboni,代码行数:26,代码来源:utils_mail.py


示例8: icons

 def icons(self):
     # TODO: Default to 64x64 icon until addressed in
     # https://bugzilla.mozilla.org/show_bug.cgi?id=981093
     return {64: absolutify(
         self.inapp.logo_url or
         urljoin(settings.MEDIA_URL, 'img/mkt/icons/rocket-64.png')
     )}
开发者ID:MaxMillion,项目名称:zamboni,代码行数:7,代码来源:webpay_jwt.py


示例9: get_url_path

 def get_url_path(self, src):
     from amo.helpers import urlparams
     from mkt.site.helpers import absolutify
     url = os.path.join(reverse('downloads.file', args=[self.id]),
                        self.filename)
     # Firefox's Add-on Manager needs absolute urls.
     return absolutify(urlparams(url, src=src))
开发者ID:andymckay,项目名称:zamboni,代码行数:7,代码来源:models.py


示例10: download_url

 def download_url(self):
     kwargs = {
         'filename': self.filename,
         'uuid': self.extension.uuid,
         'version_id': self.pk,
     }
     return absolutify(reverse('extension.download_signed', kwargs=kwargs))
开发者ID:1Smert1,项目名称:zamboni,代码行数:7,代码来源:models.py


示例11: 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:Fjoerfoks,项目名称:zamboni,代码行数:8,代码来源:test_models.py


示例12: test_issue_expired

 def test_issue_expired(self):
     data = {'receipt_type': 'expired', 'manifest_url': 'http://foo.com/'}
     res = self.client.post(self.issue, data=data)
     data = decode_receipt(json.loads(res.content)['receipt']
                               .encode('ascii'))
     eq_(data['verify'], absolutify(reverse('receipt.test.verify',
                                    kwargs={'status': 'expired'})))
     ok_(data['exp'] > (calendar.timegm(time.gmtime()) +
                        (60 * 60 * 24) - TEST_LEEWAY))
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:9,代码来源:test_views.py


示例13: test_suggestions

 def test_suggestions(self):
     response = self.client.get(self.url, data={'lang': 'en-US'})
     parsed = json.loads(response.content)
     eq_(parsed[0], '')
     self.assertSetEqual(
         parsed[1],
         [unicode(self.app1.name), unicode(self.app2.name)])
     self.assertSetEqual(
         parsed[2],
         [unicode(self.app1.description),
          unicode(truncate(self.app2.description))])
     self.assertSetEqual(
         parsed[3],
         [absolutify(self.app1.get_detail_url()),
          absolutify(self.app2.get_detail_url())])
     self.assertSetEqual(
         parsed[4],
         [self.app1.get_icon_url(64), self.app2.get_icon_url(64)])
开发者ID:andymckay,项目名称:zamboni,代码行数:18,代码来源:test_views.py


示例14: 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:Fjoerfoks,项目名称:zamboni,代码行数:10,代码来源:test_models.py


示例15: test_valid_jwt

    def test_valid_jwt(self):
        token_data = self.decode_token()
        eq_(token_data['iss'], settings.APP_PURCHASE_KEY)
        eq_(token_data['typ'], settings.APP_PURCHASE_TYP)
        eq_(token_data['aud'], settings.APP_PURCHASE_AUD)

        request = token_data['request']
        eq_(request['id'], self.product.external_id())
        eq_(request['name'], self.product.name())
        eq_(request['icons'], self.product.icons())
        eq_(request['description'], self.product.description())
        eq_(request['pricePoint'], self.product.price().name)
        eq_(request['postbackURL'], absolutify(reverse('webpay.postback')))
        eq_(request['chargebackURL'], absolutify(reverse('webpay.chargeback')))

        token_product_data = urlparse.parse_qs(request['productData'])
        expected_product_data = urlparse.parse_qs(
            urlencode(self.product.product_data(self.contribution)))
        eq_(token_product_data, expected_product_data)
开发者ID:miltonpereira,项目名称:zamboni,代码行数:19,代码来源:test_webpay_jwt.py


示例16: get_product_jwt

def get_product_jwt(product, contribution):
    """Prepare a JWT for paid products to pass into navigator.pay()"""

    issued_at = calendar.timegm(time.gmtime())
    product_data = product.product_data(contribution)
    simulation = product.simulation()
    if not simulation and not product_data.get('public_id'):
        raise ValueError(
            'Cannot create JWT without a cached public_id for '
            'app {a}'.format(a=product.addon()))

    token_data = {
        'iss': settings.APP_PURCHASE_KEY,
        'typ': settings.APP_PURCHASE_TYP,
        'aud': settings.APP_PURCHASE_AUD,
        'iat': issued_at,
        'exp': issued_at + 3600,  # expires in 1 hour
        'request': {
            'id': product.external_id(),
            'name': unicode(product.name()),
            'icons': product.icons(),
            'description': strip_tags(product.description()),
            'pricePoint': product.price().name,
            'productData': urlencode(product_data),
            'chargebackURL': absolutify(reverse('webpay.chargeback')),
            'postbackURL': absolutify(reverse('webpay.postback')),
        }
    }
    if simulation:
        token_data['request']['simulate'] = simulation

    token = sign_webpay_jwt(token_data)

    log.debug('Preparing webpay JWT for product {p}, contrib {c}: {t}'
              .format(p=product.id(), t=token_data, c=contribution))

    return {
        'webpayJWT': token,
        'contribStatusURL': reverse(
            'webpay-status',
            kwargs={'uuid': contribution.uuid}
        )
    }
开发者ID:MaxMillion,项目名称:zamboni,代码行数:43,代码来源:webpay_jwt.py


示例17: test_valid_jwt

    def test_valid_jwt(self):
        token_data = self.decode_token()
        eq_(token_data["iss"], settings.APP_PURCHASE_KEY)
        eq_(token_data["typ"], settings.APP_PURCHASE_TYP)
        eq_(token_data["aud"], settings.APP_PURCHASE_AUD)

        request = token_data["request"]
        eq_(request["id"], self.product.external_id())
        eq_(request["name"], self.product.name())
        eq_(request["defaultLocale"], self.product.default_locale())
        eq_(request["icons"], self.product.icons())
        eq_(request["description"], self.product.description())
        eq_(request["pricePoint"], self.product.price().name)
        eq_(request["postbackURL"], absolutify(reverse("webpay.postback")))
        eq_(request["chargebackURL"], absolutify(reverse("webpay.chargeback")))

        product = urlparse.parse_qs(request["productData"])
        expected = urlparse.parse_qs(urlencode(self.product.product_data(self.contribution)))
        eq_(product["buyer_email"], [self.user.email])
        eq_(product, expected)
开发者ID:clouserw,项目名称:zamboni,代码行数:20,代码来源:test_webpay_jwt.py


示例18: get_context_data

 def get_context_data(self):
     # We need to display the name in some language that is relevant to the
     # recipient(s) instead of using the reviewer's. addon.default_locale
     # should work.
     if self.addon.name.locale != self.addon.default_locale:
         lang = to_language(self.addon.default_locale)
         with translation.override(lang):
             app = Webapp.objects.get(id=self.addon.id)
     else:
         app = self.addon
     return {'name': app.name,
             'reviewer': self.request.user.name,
             'detail_url': absolutify(
                 app.get_url_path()),
             'review_url': absolutify(reverse('reviewers.apps.review',
                                              args=[app.app_slug])),
             'status_url': absolutify(app.get_dev_url('versions')),
             'comments': self.data['comments'],
             'MKT_SUPPORT_EMAIL': settings.MKT_SUPPORT_EMAIL,
             'SITE_URL': settings.SITE_URL}
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:20,代码来源:utils.py


示例19: call

 def call(self, client=None):
     client = client or OAuthClient(self.access)
     # Make a fake POST somewhere. We use POST in order to properly test db
     # pinning after auth.
     url = absolutify('/api/whatever')
     req = RequestFactory().post(url,
         HTTP_HOST='testserver',
         HTTP_AUTHORIZATION=client.sign('POST', url)[1]['Authorization'])
     req.user = AnonymousUser()
     for m in self.middlewares:
         m().process_request(req)
     return req
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:12,代码来源:test_authentication.py


示例20: send_reviewer_mail

def send_reviewer_mail(subject, template, context, emails, perm_setting=None,
                       cc=None, attachments=None, reply_to=None):
    if not reply_to:
        reply_to = settings.MKT_REVIEWERS_EMAIL

    # Link to our newfangled "Account Settings" page.
    manage_url = absolutify('/settings') + '#notifications'
    send_mail_jinja(subject, template, context, recipient_list=emails,
                    from_email=settings.MKT_REVIEWERS_EMAIL,
                    use_blacklist=False, perm_setting=perm_setting,
                    manage_url=manage_url, headers={'Reply-To': reply_to},
                    cc=cc, attachments=attachments)
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:12,代码来源:utils.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python helpers.css函数代码示例发布时间:2022-05-27
下一篇:
Python settings.ES_INDEXES类代码示例发布时间: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