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

Python providers.get_provider函数代码示例

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

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



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

示例1: verify_bango_boku_portals

    def verify_bango_boku_portals(self, app, response):
        bango = pq(response.content)('[data-provider-name=bango]')
        heading = pq('dt', bango).text()
        assert 'Bango' in heading, heading
        assert unicode(app.name) in heading, heading
        eq_(pq('dd a', bango).attr('href'),
            get_provider(name='bango').get_portal_url(app.app_slug))

        boku = pq(response.content)('[data-provider-name=boku]')
        heading = pq('dt', boku).text()
        assert 'Boku' in heading, heading
        assert unicode(app.name) in heading, heading
        eq_(pq('dd a', boku).attr('href'),
            get_provider(name='boku').get_portal_url(app.app_slug))
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:14,代码来源:test_views.py


示例2: agreement

def agreement(request, id):
    account = get_object_or_404(PaymentAccount, pk=id, user=request.user)
    provider = get_provider()
    if request.method == 'POST':
        return provider.terms_update(account)

    return provider.terms_retrieve(account)
开发者ID:AALEKH,项目名称:zamboni,代码行数:7,代码来源:views_payments.py


示例3: post_save

 def post_save(self, obj, created=False):
     """Ensure that the setup_bango method is called after creation."""
     if created:
         provider = get_provider()
         uri = provider.product_create(obj.payment_account, obj.addon)
         obj.product_uri = uri
         obj.save()
开发者ID:anushbmx,项目名称:zamboni,代码行数:7,代码来源:api_payments.py


示例4: get_provider

    def get_provider(self):
        """Returns an instance of the payment provider for this account."""
        # TODO: fix circular import. Providers imports models which imports
        # forms which imports models.
        from mkt.developers.providers import get_provider

        return get_provider(id=self.provider)
开发者ID:mrheides,项目名称:zamboni,代码行数:7,代码来源:models.py


示例5: get_payment_provider_portals

def get_payment_provider_portals(app=None, user=None):
    """
    Get a list of dicts describing the payment portals for this app or user.

    Either app or user is required.
    """
    provider_portals = []
    if app:
        q = dict(addon=app)
    elif user:
        q = dict(payment_account__user=user)
    else:
        raise ValueError('user or app is required')

    for acct in (AddonPaymentAccount.objects.filter(**q)
                 .select_related('payment_account')):
        provider = get_provider(id=acct.payment_account.provider)
        portal_url = provider.get_portal_url(acct.addon.app_slug)
        if portal_url:
            provider_portals.append({
                'provider': provider,
                'app': acct.addon,
                'portal_url': portal_url,
                'payment_account': acct.payment_account
            })
    return provider_portals
开发者ID:waseem18,项目名称:zamboni,代码行数:26,代码来源:views.py


示例6: create

 def create(self, request, *args, **kwargs):
     provider = get_provider()
     form = provider.forms['account'](request.DATA)
     if form.is_valid():
         try:
             provider = get_provider()
             obj = provider.account_create(request.amo_user, form.data)
         except HttpClientError as e:
             log.error('Client error creating Bango account; %s' % e)
             return Response(e.content,
                             status=status.HTTP_500_INTERNAL_SERVER_ERROR)
         except HttpServerError as e:
             log.error('Error creating Bango payment account; %s' % e)
             return Response(_(u'Could not connect to payment server.'),
                            status=status.HTTP_500_INTERNAL_SERVER_ERROR)
         serializer = self.get_serializer(obj)
         return Response(serializer.data, status=status.HTTP_201_CREATED)
     return Response(form.errors, status=status.HTTP_400_BAD_REQUEST)
开发者ID:anushbmx,项目名称:zamboni,代码行数:18,代码来源:api_payments.py


示例7: payment_accounts_form

def payment_accounts_form(request):
    webapp = get_object_or_404(Webapp, app_slug=request.GET.get("app_slug"))
    provider = get_provider(name=request.GET.get("provider"))
    account_list_formset = forms_payments.AccountListFormSet(
        provider_data=[{"user": request.user, "addon": webapp, "provider": p} for p in get_providers()]
    )
    account_list_form = next(form for form in account_list_formset.forms if form.provider.name == provider.name)
    return render(
        request, "developers/payments/includes/bango_accounts_form.html", {"account_list_form": account_list_form}
    )
开发者ID:ngokevin,项目名称:zamboni,代码行数:10,代码来源:views_payments.py


示例8: payment_accounts_form

def payment_accounts_form(request):
    webapp = get_object_or_404(Webapp, app_slug=request.GET.get('app_slug'))
    provider = get_provider(name=request.GET.get('provider'))
    account_list_formset = forms_payments.AccountListFormSet(
        provider_data=[
            {'user': request.user, 'addon': webapp, 'provider': p}
            for p in get_providers()])
    account_list_form = next(form for form in account_list_formset.forms
                             if form.provider.name == provider.name)
    return render(request,
                  'developers/payments/includes/bango_accounts_form.html',
                  {'account_list_form': account_list_form})
开发者ID:andymckay,项目名称:zamboni,代码行数:12,代码来源:views_payments.py


示例9: payments_accounts_add

def payments_accounts_add(request):
    provider = get_provider()
    form = provider.forms["account"](request.POST)
    if not form.is_valid():
        return json_view.error(form.errors)

    try:
        obj = provider.account_create(request.amo_user, form.cleaned_data)
    except HttpClientError as e:
        log.error("Client error create {0} account: {1}".format(provider.name, e))
        return http.HttpResponseBadRequest(json.dumps(e.content))

    return {"pk": obj.pk, "agreement-url": obj.get_agreement_url()}
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:13,代码来源:views_payments.py


示例10: payments_accounts_add

def payments_accounts_add(request):
    provider = get_provider(name=request.POST.get('provider'))
    form = provider.forms['account'](request.POST)
    if not form.is_valid():
        return json_view.error(form.errors)

    try:
        obj = provider.account_create(request.user, form.cleaned_data)
    except HttpClientError as e:
        log.error('Client error create {0} account: {1}'.format(
            provider.name, e))
        return http.HttpResponseBadRequest(json.dumps(e.content))

    return {'pk': obj.pk, 'agreement-url': obj.get_agreement_url()}
开发者ID:andymckay,项目名称:zamboni,代码行数:14,代码来源:views_payments.py


示例11: setUp

    def setUp(self):
        super(TestAccountListForm, self).setUp()
        self.addon = Addon.objects.get(pk=337141)
        self.addon.update(status=amo.STATUS_NULL, highest_status=amo.STATUS_PUBLIC)
        self.provider = get_provider(name="bango")
        self.price = Price.objects.filter()[0]
        AddonPremium.objects.create(addon=self.addon, price=self.price)

        self.user = UserProfile.objects.get(pk=31337)
        amo.set_user(self.user)

        self.other = UserProfile.objects.get(pk=999)
        self.admin = UserProfile.objects.get(email="[email protected]")

        self.kwargs = {"addon": self.addon, "provider": self.provider}
开发者ID:gurumukhi,项目名称:zamboni,代码行数:15,代码来源:test_forms_payments.py


示例12: test_create_bango

    def test_create_bango(self):
        # Return a seller object without hitting Bango.
        self.bango_patcher.package.post.return_value = {"resource_uri": "zipzap", "package_id": 123}

        res = get_provider().account_create(self.user, {"account_name": "Test Account"})
        eq_(res.name, "Test Account")
        eq_(res.user, self.user)
        eq_(res.seller_uri, "selleruri")
        eq_(res.account_id, 123)
        eq_(res.uri, "zipzap")

        self.bango_patcher.package.post.assert_called_with(
            data={"paypalEmailAddress": "[email protected]", "seller": "selleruri"}
        )

        self.bango_patcher.bank.post.assert_called_with(data={"seller_bango": "zipzap"})
开发者ID:petercpg,项目名称:zamboni,代码行数:16,代码来源:test_models.py


示例13: setUp

    def setUp(self):
        super(TestAccountListForm, self).setUp()
        self.addon = Webapp.objects.get(pk=337141)
        self.addon.update(status=mkt.STATUS_NULL,
                          highest_status=mkt.STATUS_PUBLIC)
        self.provider = get_provider(name='bango')
        self.price = Price.objects.filter()[0]
        AddonPremium.objects.create(addon=self.addon, price=self.price)

        self.user = UserProfile.objects.get(pk=31337)
        mkt.set_user(self.user)

        self.other = UserProfile.objects.get(pk=999)
        self.admin = UserProfile.objects.get(email='[email protected]')

        self.kwargs = {
            'addon': self.addon,
            'provider': self.provider,
        }
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:19,代码来源:test_forms_payments.py


示例14: test_create_bango

    def test_create_bango(self):
        # Return a seller object without hitting Bango.
        self.bango_patcher.package.post.return_value = {
            'resource_uri': 'zipzap',
            'package_id': 123,
        }

        res = get_provider().account_create(
            self.user, {'account_name': 'Test Account'})
        eq_(res.name, 'Test Account')
        eq_(res.user, self.user)
        eq_(res.seller_uri, 'selleruri')
        eq_(res.account_id, 123)
        eq_(res.uri, 'zipzap')

        self.bango_patcher.package.post.assert_called_with(
            data={'paypalEmailAddress': '[email protected]',
                  'seller': 'selleruri'})

        self.bango_patcher.bank.post.assert_called_with(
            data={'seller_bango': 'zipzap'})
开发者ID:MorrisJobke,项目名称:zamboni,代码行数:21,代码来源:test_models.py


示例15: setUp

    def setUp(self):
        super(TestPaidRereview, self).setUp()
        self.addon = Addon.objects.get(pk=337141)
        self.addon.update(status=amo.STATUS_NULL,
                          highest_status=amo.STATUS_PUBLIC)
        self.provider = get_provider(name='bango')
        self.price = Price.objects.filter()[0]
        AddonPremium.objects.create(addon=self.addon, price=self.price)
        self.user = UserProfile.objects.get(email='[email protected]')
        amo.set_user(self.user)
        seller = models.SolitudeSeller.objects.create(
            resource_uri='/path/to/sel', user=self.user)

        self.account = models.PaymentAccount.objects.create(
            user=self.user, uri='asdf', name='test', inactive=False,
            solitude_seller=seller, account_id=123, agreed_tos=True)

        self.kwargs = {
            'addon': self.addon,
            'user': self.user,
            'provider': self.provider,
        }
开发者ID:Dreadchild,项目名称:zamboni,代码行数:22,代码来源:test_forms_payments.py


示例16: perform_create

    def perform_create(self, serializer, created=True):
        if not AddonPaymentAccountPermission().check(
                self.request,
                serializer.validated_data['addon'],
                serializer.validated_data['payment_account']):
            raise PermissionDenied('Not allowed to alter that object.')

        if self.request.method != 'POST':
            if not self.queryset.filter(
                    addon=serializer.validated_data['addon'],
                    payment_account=serializer.validated_data[
                        'payment_account']).exists():
                # This should be a 400 error.
                raise PermissionDenied('Cannot change the add-on.')

        obj = serializer.save()

        if created:
            provider = get_provider()
            uri = provider.product_create(obj.payment_account, obj.addon)
            obj.product_uri = uri
        obj.save()
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:22,代码来源:api_payments.py


示例17: save

    def save(self):
        if self.cleaned_data.get('accounts'):
            try:
                log.info('[[email protected]%s] Deleting app payment account' % self.addon.pk)
                AddonPaymentAccount.objects.get(addon=self.addon).delete()
            except AddonPaymentAccount.DoesNotExist:
                pass

            log.info('[[email protected]%s] Creating new app payment account' % self.addon.pk)
            from mkt.developers.providers import get_provider

            provider = get_provider()
            account = self.cleaned_data['accounts']

            uri = provider.product_create(account, self.addon)
            AddonPaymentAccount.objects.create(
                addon=self.addon, account_uri=account.uri,
                payment_account=account, product_uri=uri)

            # If the app is marked as paid and the information is complete
            # and the app is currently marked as incomplete, put it into the
            # re-review queue.
            if (self.addon.status == amo.STATUS_NULL and
                self.addon.highest_status in amo.WEBAPPS_APPROVED_STATUSES):
                # FIXME: This might cause noise in the future if bank accounts
                # get manually closed by Bango and we mark apps as STATUS_NULL
                # until a new account is selected. That will trigger a
                # re-review.

                log.info(u'[Webapp:%s] (Re-review) Public app, premium type '
                         u'upgraded.' % self.addon)
                RereviewQueue.flag(
                    self.addon, amo.LOG.REREVIEW_PREMIUM_TYPE_UPGRADE)

            if self.addon.has_incomplete_status() and self.addon.is_fully_complete():
                _restore_app_status(self.addon)
开发者ID:imclab,项目名称:olympia,代码行数:36,代码来源:forms_payments.py


示例18: test_multiple

 def test_multiple(self):
     with self.settings(PAYMENT_PROVIDERS=["foo", "bar"]):
         get_provider()
开发者ID:spasovski,项目名称:zamboni,代码行数:3,代码来源:test_providers.py


示例19: test_multiple

 def test_multiple(self):
     with self.settings(PAYMENT_PROVIDERS=['bango', 'reference'],
                        DEFAULT_PAYMENT_PROVIDER='bango'):
         eq_(get_provider().name, 'bango')
开发者ID:BIGGANI,项目名称:zamboni,代码行数:4,代码来源:test_providers.py


示例20: payments

def payments(request, addon_id, addon, webapp=False):
    premium_form = forms_payments.PremiumForm(request.POST or None, request=request, addon=addon, user=request.amo_user)

    region_form = forms.RegionForm(request.POST or None, product=addon, request=request)

    upsell_form = forms_payments.UpsellForm(request.POST or None, addon=addon, user=request.amo_user)

    account_list_form = forms_payments.AccountListForm(request.POST or None, addon=addon, user=request.amo_user)

    if request.method == "POST":

        success = all(form.is_valid() for form in [premium_form, region_form, upsell_form, account_list_form])

        if success:
            region_form.save()

            try:
                premium_form.save()
            except client.Error as err:
                success = False
                log.error("Error setting payment information (%s)" % err)
                messages.error(request, _(u"We encountered a problem connecting to the " u"payment server."))
                raise  # We want to see these exceptions!

            is_free_inapp = addon.premium_type == amo.ADDON_FREE_INAPP
            is_now_paid = addon.premium_type in amo.ADDON_PREMIUMS or is_free_inapp

            # If we haven't changed to a free app, check the upsell.
            if is_now_paid and success:
                try:
                    if not is_free_inapp:
                        upsell_form.save()
                    account_list_form.save()
                except client.Error as err:
                    log.error("Error saving payment information (%s)" % err)
                    messages.error(request, _(u"We encountered a problem connecting to " u"the payment server."))
                    success = False
                    raise  # We want to see all the solitude errors now.

        # If everything happened successfully, give the user a pat on the back.
        if success:
            messages.success(request, _("Changes successfully saved."))
            return redirect(addon.get_dev_url("payments"))

    # TODO: refactor this (bug 945267)
    is_packaged = addon.is_packaged
    android_payments_enabled = waffle.flag_is_active(request, "android-payments")
    android_packaged_enabled = waffle.flag_is_active(request, "android-packaged")
    desktop_packaged_enabled = waffle.flag_is_active(request, "desktop-packaged")

    # If android payments is not allowed then firefox os must
    # be 'checked' and android-mobile and android-tablet should not be.
    invalid_paid_platform_state = []

    # If isn't packaged or it is packaged and the android-packaged flag is on
    # then we should check that desktop isn't set to True.
    if not is_packaged or (is_packaged and desktop_packaged_enabled):
        invalid_paid_platform_state.append(("desktop", True))

    if not android_payments_enabled:
        # When android-payments is off...
        # If isn't packaged or it is packaged and the android-packaged flag is on
        # then we should check for the state of android-mobile and android-tablet.
        if not is_packaged or (is_packaged and android_packaged_enabled):
            invalid_paid_platform_state += [("android-mobile", True), ("android-tablet", True)]
        invalid_paid_platform_state.append(("firefoxos", False))

    cannot_be_paid = addon.premium_type == amo.ADDON_FREE and any(
        premium_form.device_data["free-%s" % x] == y for x, y in invalid_paid_platform_state
    )

    try:
        tier_zero = Price.objects.get(price="0.00", active=True)
        tier_zero_id = tier_zero.pk
    except Price.DoesNotExist:
        tier_zero = None
        tier_zero_id = ""

    # Get the regions based on tier zero. This should be all the
    # regions with payments enabled.
    paid_region_ids_by_slug = []
    if tier_zero:
        paid_region_ids_by_slug = tier_zero.region_ids_by_slug()

    provider = get_provider()
    paid_platform_names = [unicode(platform[1]) for platform in PAID_PLATFORMS(request, is_packaged)]

    return render(
        request,
        "developers/payments/premium.html",
        {
            "addon": addon,
            "webapp": webapp,
            "premium": addon.premium,
            "form": premium_form,
            "upsell_form": upsell_form,
            "tier_zero_id": tier_zero_id,
            "region_form": region_form,
            "DEVICE_LOOKUP": DEVICE_LOOKUP,
            "is_paid": (addon.premium_type in amo.ADDON_PREMIUMS or addon.premium_type == amo.ADDON_FREE_INAPP),
#.........这里部分代码省略.........
开发者ID:nearlyfreeapps,项目名称:zamboni,代码行数:101,代码来源:views_payments.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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