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

Python carriers.get_carrier函数代码示例

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

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



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

示例1: manifest

def manifest(request):
    ctx = RequestContext(request)
    data = {
        "name": getattr(settings, "WEBAPP_MANIFEST_NAME", "Firefox Marketplace"),
        "description": "The Firefox Marketplace",
        "developer": {"name": "Mozilla", "url": "http://mozilla.org"},
        "icons": {
            # Using the default addon image until we get a marketplace logo.
            "128": media(ctx, "img/mkt/logos/128.png"),
            "64": media(ctx, "img/mkt/logos/64.png"),
            "32": media(ctx, "img/mkt/logos/32.png"),
        },
        "activities": {
            "marketplace-app": {"href": "/"},
            "marketplace-app-rating": {"href": "/"},
            "marketplace-category": {"href": "/"},
            "marketplace-search": {"href": "/"},
        },
    }
    if get_carrier():
        data["launch_path"] = urlparams("/", carrier=get_carrier())

    manifest_content = json.dumps(data)
    manifest_etag = hashlib.sha256(manifest_content).hexdigest()

    @etag(lambda r: manifest_etag)
    def _inner_view(request):
        response = HttpResponse(manifest_content, content_type="application/x-web-app-manifest+json")
        return response

    return _inner_view(request)
开发者ID:gurumukhi,项目名称:zamboni,代码行数:31,代码来源:views.py


示例2: test_set_carrier_to_none_url

    def test_set_carrier_to_none_url(self):
        self.get('/telefonica/')
        self.get('/not-a-store')
        eq_(get_carrier(), None)

        self.get('/?carrier=telefonica')
        self.get('/?carrier=not-a-store')
        eq_(get_carrier(), None)
开发者ID:j-barron,项目名称:zamboni,代码行数:8,代码来源:tests.py


示例3: process_response

 def process_response(self, request, response):
     if getattr(request, 'API', False) and response.status_code < 500:
         filters = (
             ('carrier', get_carrier() or ''),
             ('lang', request.LANG),
             ('pro', request.GET.get('pro', '')),
             ('region', request.REGION.slug),
         )
         response['API-Filter'] = urlencode(filters, doseq=True)
         patch_vary_headers(response, ['API-Filter'])
     return response
开发者ID:unghost,项目名称:zamboni,代码行数:11,代码来源:middleware.py


示例4: featured

    def featured(self, cat=None, region=None, limit=9, mobile=False,
                 gaia=False, tablet=False):
        """
        Filters the QuerySet, removing FeaturedApp instances that should
        not be featured based on the passed criteria.

        If a region is defined and there are fewer than `limit` items
        remaining in the resultant queryset, the difference is populated by
        additional apps that are featured worldwide.
        """
        qs = self.active()
        Webapp = get_model('webapps', 'Webapp')

        excluded = Webapp.objects.none()
        if region:
            from mkt.webapps.models import get_excluded_in
            excluded = get_excluded_in(region.id)

        if waffle.switch_is_active('disabled-payments') or not gaia:
            qs = qs.filter(app__premium_type__in=amo.ADDON_FREES)

        qs = qs.for_category(cat)

        carrier = get_carrier()
        if carrier:
            qs = qs.for_carrier(carrier)

        if gaia:
            qs = qs.gaia()
        elif mobile:
            qs = qs.mobile()

        if tablet:
            qs = qs.tablet()

        qs_pre_region = qs._clone()

        if region:
            qs = qs.for_region(region).exclude(app__id__in=excluded)

            # Fill the empty spots with Worldwide-featured apps.
            if limit:
                empty_spots = limit - qs.count()
                if empty_spots > 0 and region != mkt.regions.WORLDWIDE:
                    qs |= (qs_pre_region.worldwide()
                           .exclude(id__in=[x.id for x in qs])
                           .exclude(app__id__in=excluded))

        if limit:
            qs = qs[:limit]

        return qs
开发者ID:jlongster,项目名称:zamboni,代码行数:52,代码来源:models.py


示例5: manifest

def manifest(request):
    ctx = RequestContext(request)
    data = {
        'name': getattr(settings, 'WEBAPP_MANIFEST_NAME',
                        'Firefox Marketplace'),
        'description': 'The Firefox Marketplace',
        'developer': {
            'name': 'Mozilla',
            'url': 'http://mozilla.org',
        },
        'icons': {
            # Using the default addon image until we get a marketplace logo.
            '128': media(ctx, 'img/mkt/logos/128.png'),
            '64': media(ctx, 'img/mkt/logos/64.png'),
            '32': media(ctx, 'img/mkt/logos/32.png'),
        },
        'activities': {
            'marketplace-app': {'href': '/'},
            'marketplace-app-rating': {'href': '/'},
            'marketplace-category': {'href': '/'},
            'marketplace-search': {'href': '/'},
        },
        'orientation': ['portrait-primary']
    }
    if settings.USE_APPCACHE:
        data['appcache_path'] = reverse('django_appcache.manifest')
    if get_carrier():
        data['launch_path'] = urlparams('/', carrier=get_carrier())

    manifest_content = json.dumps(data)
    manifest_etag = hashlib.md5(manifest_content).hexdigest()

    @etag(lambda r: manifest_etag)
    def _inner_view(request):
        response = HttpResponse(manifest_content,
                                mimetype='application/x-web-app-manifest+json')
        return response

    return _inner_view(request)
开发者ID:chenzihui,项目名称:zamboni,代码行数:39,代码来源:views.py


示例6: manifest

def manifest(request):
    ctx = RequestContext(request)
    for processor in get_standard_processors():
        ctx.update(processor(request))
    data = {
        'name': getattr(settings, 'WEBAPP_MANIFEST_NAME',
                        'Firefox Marketplace'),
        'description': 'The Firefox Marketplace',
        'developer': {
            'name': 'Mozilla',
            'url': 'http://mozilla.org',
        },
        'icons': {
            # Using the default addon image until we get a marketplace logo.
            '128': media(ctx, 'img/mkt/logos/128.png'),
            '64': media(ctx, 'img/mkt/logos/64.png'),
            '32': media(ctx, 'img/mkt/logos/32.png'),
        },
        'activities': {
            'marketplace-app': {'href': '/'},
            'marketplace-app-rating': {'href': '/'},
            'marketplace-category': {'href': '/'},
            'marketplace-search': {'href': '/'},
        }
    }
    if get_carrier():
        data['launch_path'] = urlparams('/', carrier=get_carrier())

    manifest_content = json.dumps(data)
    manifest_etag = hashlib.sha256(manifest_content).hexdigest()

    @etag(lambda r: manifest_etag)
    def _inner_view(request):
        response = HttpResponse(
            manifest_content,
            content_type='application/x-web-app-manifest+json')
        return response

    return _inner_view(request)
开发者ID:Fjoerfoks,项目名称:zamboni,代码行数:39,代码来源:views.py


示例7: process_response

 def process_response(self, request, response):
     if getattr(request, 'API', False) and response.status_code < 500:
         devices = []
         for device in ('GAIA', 'MOBILE', 'TABLET'):
             if getattr(request, device, False):
                 devices.append(device.lower())
         filters = (
             ('carrier', get_carrier() or ''),
             ('device', devices),
             ('lang', request.LANG),
             ('region', request.REGION.slug),
         )
         response['API-Filter'] = urlencode(filters, doseq=True)
         patch_vary_headers(response, ['API-Filter'])
     return response
开发者ID:jlongster,项目名称:zamboni,代码行数:15,代码来源:middleware.py


示例8: process_response

 def process_response(self, request, response):
     if getattr(request, "API", False) and response.status_code < 500:
         devices = []
         for device in ("GAIA", "MOBILE", "TABLET"):
             if getattr(request, device, False):
                 devices.append(device.lower())
         filters = (
             ("carrier", get_carrier() or ""),
             ("device", devices),
             ("lang", request.LANG),
             ("pro", request.GET.get("pro", "")),
             ("region", request.REGION.slug),
         )
         response["API-Filter"] = urlencode(filters, doseq=True)
         patch_vary_headers(response, ["API-Filter"])
     return response
开发者ID:cvan,项目名称:zamboni,代码行数:16,代码来源:middleware.py


示例9: process_response

    def process_response(self, request, response):
        if (request.method == 'POST' and
                request.POST.get('_hijacked', False) and
                response.status_code in (301, 302)):
            view_url = location = response['Location']
            frag_bust = response.get('x-frag-bust', None)

            # TODO: We should remove the need for this.
            if get_carrier():
                # Strip carrier from URL.
                view_url = '/' + '/'.join(location.split('/')[2:])

            req = copy.copy(request)
            req.method = 'GET'
            req.path = view_url
            # We want only the fragment response.
            req.META['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
            # Pass back the URI so we can pushState it.
            req.FRAGMENT_URI = location

            view = resolve(urllib.unquote(view_url).decode('utf-8'))
            response = view.func(req, *view.args, **view.kwargs)

            response['X-URI'] = location
            # If we have a fragment cache bust flag on the first request,
            # perpetrate it on the new request.
            if frag_bust:
                # If there's a fragment bust flag in the new request, merge it
                # with the flag from the old request in the second grossest
                # possible way.
                if 'x-frag-bust' in response:
                    frag_bust = json.dumps(
                        json.loads(frag_bust) +
                        json.loads(response['x-frag-bust']))

                response['x-frag-bust'] = frag_bust

        return response
开发者ID:MaxDumont,项目名称:zamboni,代码行数:38,代码来源:middleware.py


示例10: test_set_carrier_none

 def test_set_carrier_none(self):
     request = self.request('/?carrier=')
     request.COOKIES = {'carrier': 'telefonica'}
     request = self.get('/?carrier=', request)
     eq_(get_carrier(), None)
     assert request.set_cookie.called
开发者ID:j-barron,项目名称:zamboni,代码行数:6,代码来源:tests.py


示例11: test_set_carrier

 def test_set_carrier(self):
     request = self.get('/?carrier=telefonica')
     eq_(get_carrier(), 'telefonica')
     assert request.set_cookie.called
开发者ID:j-barron,项目名称:zamboni,代码行数:4,代码来源:tests.py


示例12: featured

    def featured(self, cat=None, region=None, limit=9, mobile=False,
                 gaia=False, tablet=False, profile=None):
        """
        Filters the QuerySet, removing FeaturedApp instances that should
        not be featured based on the passed criteria.

        If a region is defined and there are fewer than `limit` items
        remaining in the resultant queryset, the difference is populated by
        additional apps that are featured worldwide.

        If `profile` (a FeatureProfile object) is provided we filter by the
        profile. If you don't want to filter by these don't pass it. I.e. do
        the device detection for when this happens elsewhere.

        """
        qs = self.active()
        Webapp = get_model('webapps', 'Webapp')

        excluded = Webapp.objects.none()
        if region:
            from mkt.webapps.models import get_excluded_in
            excluded = get_excluded_in(region.id)

        if waffle.switch_is_active('disabled-payments') or not gaia:
            qs = qs.filter(app__premium_type__in=amo.ADDON_FREES)

        qs = qs.for_category(cat)

        carrier = get_carrier()
        if carrier:
            qs = qs.for_carrier(carrier)

        if gaia:
            qs = qs.gaia()
        elif mobile:
            qs = qs.mobile()

        if tablet:
            qs = qs.tablet()

        if profile and waffle.switch_is_active('buchets'):
            # Exclude apps that require any features we don't support.
            qs = qs.filter(**profile.to_kwargs(
                prefix='app___current_version__features__has_'))

        qs_pre_region = qs._clone()

        if region:
            qs = qs.for_region(region).exclude(app__id__in=excluded)

            # Fill the empty spots with Worldwide-featured apps.
            if limit:
                empty_spots = limit - qs.count()
                if empty_spots > 0 and region != mkt.regions.WORLDWIDE:
                    qs |= (qs_pre_region.worldwide()
                           .exclude(id__in=[x.id for x in qs])
                           .exclude(app__id__in=excluded))

        if limit:
            qs = qs[:limit]

        return qs
开发者ID:almosteverywhere,项目名称:zamboni,代码行数:62,代码来源:models.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python serializers.CollectionSerializer类代码示例发布时间:2022-05-27
下一篇:
Python test_oauth.RestOAuthClient类代码示例发布时间: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