当前位置: 首页>>代码示例>>Python>>正文


Python providers.get_provider函数代码示例

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


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


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