本文整理汇总了Python中mkt.developers.providers.get_providers函数的典型用法代码示例。如果您正苦于以下问题:Python get_providers函数的具体用法?Python get_providers怎么用?Python get_providers使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_providers函数的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: payment_accounts
def payment_accounts(request):
app_slug = request.GET.get('app-slug', '')
accounts = PaymentAccount.objects.filter(
user=request.amo_user,
provider__in=[p.provider for p in get_providers()],
inactive=False)
def account(acc):
app_names = (', '.join(unicode(apa.addon.name)
for apa in acc.addonpaymentaccount_set.all()
if hasattr(apa, 'addon')))
provider = acc.get_provider()
data = {
'account-url':
reverse('mkt.developers.provider.payment_account',
args=[acc.pk]),
'agreement-url': acc.get_agreement_url(),
'agreement': 'accepted' if acc.agreed_tos else 'rejected',
'app-names': jinja2.escape(app_names),
'delete-url':
reverse('mkt.developers.provider.delete_payment_account',
args=[acc.pk]),
'id': acc.pk,
'name': jinja2.escape(unicode(acc)),
'provider': provider.name,
'provider-full': unicode(provider.full),
'shared': acc.shared,
'portal-url': provider.get_portal_url(app_slug)
}
return data
return map(account, accounts)
示例2: 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})
示例3: payment_accounts
def payment_accounts(request):
app_slug = request.GET.get('app-slug', '')
if app_slug:
app = Webapp.objects.get(app_slug=app_slug)
app_name = app.name
else:
app_name = ''
accounts = PaymentAccount.objects.filter(
user=request.user,
provider__in=[p.provider for p in get_providers()],
inactive=False)
def account(acc):
def payment_account_names(app):
account_names = [unicode(acc.payment_account)
for acc in app.all_payment_accounts()]
return (unicode(app.name), account_names)
addon_payment_accounts = acc.addonpaymentaccount_set.all()
associated_apps = [apa.addon
for apa in addon_payment_accounts
if hasattr(apa, 'addon')]
app_names = u', '.join(unicode(app.name) for app in associated_apps)
app_payment_accounts = json.dumps(dict([payment_account_names(app)
for app in associated_apps]))
provider = acc.get_provider()
data = {
'account-url': reverse('mkt.developers.provider.payment_account',
args=[acc.pk]),
'agreement-url': acc.get_agreement_url(),
'agreement': 'accepted' if acc.agreed_tos else 'rejected',
'current-app-name': jinja2.escape(app_name),
'app-names': jinja2.escape(app_names),
'app-payment-accounts': jinja2.escape(app_payment_accounts),
'delete-url': reverse(
'mkt.developers.provider.delete_payment_account',
args=[acc.pk]),
'id': acc.pk,
'name': jinja2.escape(unicode(acc)),
'provider': provider.name,
'provider-full': unicode(provider.full),
'shared': acc.shared,
'portal-url': provider.get_portal_url(app_slug)
}
return data
return map(account, accounts)
示例4: provider_regions
def provider_regions(self):
"""A dict of provider regions keyed by provider id.
Sorted by name (except for rest of world which is
always last).
"""
# Avoid circular import.
from mkt.developers.providers import get_providers
provider_regions = {}
providers = get_providers()
for prv in providers:
provider_regions[prv.provider] = self.regions_by_name(
provider=prv.provider)
return provider_regions
示例5: payment_accounts
def payment_accounts(request):
app_slug = request.GET.get("app-slug", "")
if app_slug:
app = Webapp.objects.get(app_slug=app_slug)
app_name = app.name
else:
app_name = ""
accounts = PaymentAccount.objects.filter(
user=request.user, provider__in=[p.provider for p in get_providers()], inactive=False
)
def account(acc):
def payment_account_names(app):
account_names = [unicode(acc.payment_account) for acc in app.all_payment_accounts()]
return (unicode(app.name), account_names)
addon_payment_accounts = acc.addonpaymentaccount_set.all()
associated_apps = [apa.addon for apa in addon_payment_accounts if hasattr(apa, "addon")]
app_names = u", ".join(unicode(app.name) for app in associated_apps)
app_payment_accounts = json.dumps(dict([payment_account_names(app) for app in associated_apps]))
provider = acc.get_provider()
data = {
"account-url": reverse("mkt.developers.provider.payment_account", args=[acc.pk]),
"agreement-url": acc.get_agreement_url(),
"agreement": "accepted" if acc.agreed_tos else "rejected",
"current-app-name": jinja2.escape(app_name),
"app-names": jinja2.escape(app_names),
"app-payment-accounts": jinja2.escape(app_payment_accounts),
"delete-url": reverse("mkt.developers.provider.delete_payment_account", args=[acc.pk]),
"id": acc.pk,
"name": jinja2.escape(unicode(acc)),
"provider": provider.name,
"provider-full": unicode(provider.full),
"shared": acc.shared,
"portal-url": provider.get_portal_url(app_slug),
}
return data
return map(account, accounts)
示例6: payments
def payments(request, addon_id, addon, webapp=False):
premium_form = forms_payments.PremiumForm(
request.POST or None, request=request, addon=addon,
user=request.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.user)
providers = get_providers()
if 'form-TOTAL_FORMS' in request.POST:
formset_data = request.POST
else:
formset_data = None
account_list_formset = forms_payments.AccountListFormSet(
data=formset_data,
provider_data=[
{'addon': addon, 'user': request.user, 'provider': provider}
for provider in providers])
if request.method == 'POST':
active_forms = [premium_form, region_form, upsell_form]
if formset_data is not None:
active_forms.append(account_list_formset)
success = all(form.is_valid() for form in active_forms)
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()
if formset_data is not None:
account_list_formset.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))
#.........这里部分代码省略.........
示例7: payments
def payments(request, addon_id, addon, webapp=False):
premium_form = forms_payments.PremiumForm(request.POST or None, request=request, addon=addon, user=request.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.user)
providers = get_providers()
if "form-TOTAL_FORMS" in request.POST:
formset_data = request.POST
else:
formset_data = None
account_list_formset = forms_payments.AccountListFormSet(
data=formset_data,
provider_data=[{"addon": addon, "user": request.user, "provider": provider} for provider in providers],
)
if request.method == "POST":
active_forms = [premium_form, region_form, upsell_form]
if formset_data is not None:
active_forms.append(account_list_formset)
success = all(form.is_valid() for form in active_forms)
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()
if formset_data is not None:
account_list_formset.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)
android_payments_enabled = waffle.flag_is_active(request, "android-payments")
# 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 = [("desktop", True)]
if not android_payments_enabled:
# When android-payments is off...
invalid_paid_platform_state += [("android-mobile", True), ("android-tablet", True), ("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_name = []
if tier_zero:
paid_region_ids_by_name = tier_zero.region_ids_by_name()
platforms = PAID_PLATFORMS(request)
paid_platform_names = [unicode(platform[1]) for platform in platforms]
provider_regions = {}
if tier_zero:
provider_regions = tier_zero.provider_regions()
return render(
request,
"developers/payments/premium.html",
{
"addon": addon,
"webapp": webapp,
"premium": addon.premium,
#.........这里部分代码省略.........
示例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}
)