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

Python providers.get_providers函数代码示例

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

本文整理汇总了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)
开发者ID:lissyx,项目名称:zamboni,代码行数:32,代码来源:views_payments.py


示例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})
开发者ID:andymckay,项目名称:zamboni,代码行数:12,代码来源:views_payments.py


示例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)
开发者ID:andymckay,项目名称:zamboni,代码行数:47,代码来源:views_payments.py


示例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
开发者ID:clouserw,项目名称:zamboni,代码行数:17,代码来源:models.py


示例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)
开发者ID:ngokevin,项目名称:zamboni,代码行数:39,代码来源:views_payments.py


示例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))
#.........这里部分代码省略.........
开发者ID:andymckay,项目名称:zamboni,代码行数:101,代码来源:views_payments.py


示例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,
#.........这里部分代码省略.........
开发者ID:ngokevin,项目名称:zamboni,代码行数:101,代码来源: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:ngokevin,项目名称:zamboni,代码行数:10,代码来源:views_payments.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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