本文整理汇总了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))
示例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)
示例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()
示例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)
示例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
示例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)
示例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}
)
示例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})
示例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()}
示例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()}
示例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}
示例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"})
示例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,
}
示例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'})
示例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,
}