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

Python utils.parse_region函数代码示例

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

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



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

示例1: test_parse_region

def test_parse_region():
    eq_(parse_region('worldwide'), regions.WORLDWIDE)
    eq_(parse_region('br'), regions.BR)
    eq_(parse_region('7'), regions.BR)
    eq_(parse_region(7), regions.BR)
    eq_(parse_region(regions.BR), regions.BR)
    assert_raises(KeyError, parse_region, '')
开发者ID:magopian,项目名称:zamboni,代码行数:7,代码来源:test_utils_.py


示例2: test_parse_region

def test_parse_region():
    eq_(parse_region('worldwide'), regions.WORLDWIDE)
    eq_(parse_region('br'), regions.BR)
    eq_(parse_region('brazil'), regions.BR)
    eq_(parse_region('bRaZiL'), regions.BR)
    eq_(parse_region('7'), regions.BR)
    eq_(parse_region(7), regions.BR)
    eq_(parse_region(regions.BR), regions.BR)
    eq_(parse_region(''), None)
开发者ID:aricha,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py


示例3: test_parse_region

def test_parse_region():
    eq_(parse_region('restofworld'), regions.RESTOFWORLD)
    eq_(parse_region('br'), regions.BR)
    eq_(parse_region('brazil'), regions.BR)
    eq_(parse_region('bRaZiL'), regions.BR)
    eq_(parse_region('7'), regions.BR)
    eq_(parse_region(7), regions.BR)
    eq_(parse_region(regions.BR), regions.BR)
    eq_(parse_region(''), None)
开发者ID:AALEKH,项目名称:zamboni,代码行数:9,代码来源:test_utils_.py


示例4: check_reviewer

def check_reviewer(request, region=None):
    if region is not None:
        # This is for reviewers in special regions (e.g., China).
        from mkt.regions.utils import parse_region
        region_slug = parse_region(region).slug.upper()
        return action_allowed(request, 'Apps', 'ReviewRegion%s' % region_slug)

    return action_allowed(request, 'Apps', 'Review')
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:8,代码来源:acl.py


示例5: post

    def post(self, request, pk, region, *args, **kwargs):
        app = self.get_object()
        region = parse_region(region)

        form = ApproveRegionForm(request.DATA, app=app, region=region)
        if not form.is_valid():
            raise ParseError(dict(form.errors.items()))
        form.save()

        return Response({'approved': bool(form.cleaned_data['approve'])})
开发者ID:petercpg,项目名称:zamboni,代码行数:10,代码来源:views.py


示例6: check_reviewer

def check_reviewer(request, only=None, region=None):
    if only == 'app' and region is not None:
        # This is for reviewers in special regions (e.g., China).
        from mkt.regions.utils import parse_region
        region_slug = parse_region(region).slug.upper()
        return action_allowed(request, 'Apps', 'ReviewRegion%s' % region_slug)

    addon = action_allowed(request, 'Addons', 'Review')
    app = action_allowed(request, 'Apps', 'Review')
    if only == 'addon':
        return addon
    elif only == 'app':
        return app
    return addon or app
开发者ID:BIGGANI,项目名称:zamboni,代码行数:14,代码来源:acl.py


示例7: queue_region

def queue_region(request, region=None):
    # TODO: Create a landing page that lists all the special regions.
    if region is None:
        raise http.Http404

    region = parse_region(region)
    column = '_geodata__region_%s_nominated' % region.slug

    qs = Webapp.objects.pending_in_region(region)

    apps = [QueuedApp(app, app.geodata.get_nominated_date(region))
            for app in _do_sort(request, qs, date_sort=column)]

    return _queue(request, apps, 'region', date_sort=column,
                  template='reviewers/queue_region.html',
                  data={'region': region})
开发者ID:petercpg,项目名称:zamboni,代码行数:16,代码来源:views.py


示例8: handle

    def handle(self, *args, **options):
        # Avoid import error.
        from mkt.regions.utils import parse_region
        from mkt.webapps.models import Webapp

        try:
            region_slug = args[0]
        except IndexError:
            raise CommandError(self.help)

        region = parse_region(region_slug)

        for app in Webapp.objects.all():
            aer, created = app.webappexcludedregion.get_or_create(region=region.id)
            if created:
                log.info("[App %s - %s] Excluded in region %r" % (app.pk, app.app_slug, region.slug))
开发者ID:shahbaz17,项目名称:zamboni,代码行数:16,代码来源:exclude_region.py


示例9: queue_region

def queue_region(request, region=None):
    # TODO: Create a landing page that lists all the special regions.
    if region is None:
        raise http.Http404

    region = parse_region(region)
    column = '_geodata__region_%s_nominated' % region.slug

    queues_helper = ReviewersQueuesHelper(request)
    qs = Webapp.objects.pending_in_region(region)
    apps = [ActionableQueuedApp(app, app.geodata.get_nominated_date(region),
                                reverse('approve-region',
                                        args=[app.id, region.slug]))
            for app in queues_helper.sort(qs, date_sort=column)]

    return _queue(request, apps, 'region', date_sort=column,
                  template='reviewers/queue_region.html',
                  data={'region': region})
开发者ID:carriercomm,项目名称:zamboni,代码行数:18,代码来源:views.py


示例10: get_queryset

 def get_queryset(self):
     region = parse_region(self.request.parser_context['kwargs']['region'])
     return self.model.objects.pending_in_region(region)
开发者ID:petercpg,项目名称:zamboni,代码行数:3,代码来源:views.py


示例11: get_permissions

 def get_permissions(self):
     region = parse_region(self.request.parser_context['kwargs']['region'])
     region_slug = region.slug.upper()
     return (GroupPermission('Apps', 'ReviewRegion%s' % region_slug),)
开发者ID:petercpg,项目名称:zamboni,代码行数:4,代码来源:views.py


示例12: import

from mkt.versions.models import Version
from mkt.webapps.forms import clean_slug, clean_tags, icons
from mkt.webapps.models import (Addon, AddonUser, BlacklistedSlug, IARCInfo,
                                Preview, Webapp)
from mkt.webapps.tasks import index_webapps, update_manifests
from mkt.webapps.widgets import IconWidgetRenderer

from . import tasks


log = commonware.log.getLogger('mkt.developers')


region_error = lambda region: forms.ValidationError(
    _('You cannot select {region}.').format(
        region=unicode(parse_region(region).name)
    )
)


def toggle_app_for_special_regions(request, app, enabled_regions=None):
    """Toggle for special regions (e.g., China)."""
    if not waffle.flag_is_active(request, 'special-regions'):
        return

    for region in mkt.regions.SPECIAL_REGIONS:
        status = app.geodata.get_status(region)

        if enabled_regions is not None:
            if region.id in enabled_regions:
                # If it's not already enabled, mark as pending.
开发者ID:kylewu,项目名称:zamboni,代码行数:31,代码来源:forms.py


示例13: region_error

def region_error(region):
    return forms.ValidationError(_('You cannot select {region}.').format(
        region=unicode(parse_region(region).name)
    ))
开发者ID:ujdhesa,项目名称:zamboni,代码行数:4,代码来源:forms.py


示例14: test_parse_worldwide_region_as_restofworld

def test_parse_worldwide_region_as_restofworld():
    eq_(parse_region('worldwide'), regions.RESTOFWORLD)
开发者ID:AALEKH,项目名称:zamboni,代码行数:2,代码来源:test_utils_.py


示例15: _

from mkt.translations.models import Translation
from mkt.translations.widgets import TranslationTextarea, TransTextarea
from mkt.versions.models import Version
from mkt.webapps.forms import clean_slug, clean_tags, icons
from mkt.webapps.models import Addon, AddonUser, BlacklistedSlug, IARCInfo, Preview, Webapp
from mkt.webapps.tasks import index_webapps, set_storefront_data, update_manifests
from mkt.webapps.widgets import IconWidgetRenderer

from . import tasks


log = commonware.log.getLogger("mkt.developers")


region_error = lambda region: forms.ValidationError(
    _("You cannot select {region}.").format(region=unicode(parse_region(region).name))
)


def toggle_app_for_special_regions(request, app, enabled_regions=None):
    """Toggle for special regions (e.g., China)."""
    if not waffle.flag_is_active(request, "special-regions"):
        return

    for region in mkt.regions.SPECIAL_REGIONS:
        status = app.geodata.get_status(region)

        if enabled_regions is not None:
            if region.id in enabled_regions:
                # If it's not already enabled, mark as pending.
                if status != amo.STATUS_PUBLIC:
开发者ID:gurumukhi,项目名称:zamboni,代码行数:31,代码来源:forms.py


示例16: get_object

 def get_object(self, *args, **kwargs):
     region = parse_region(self.kwargs['pk'])
     if region is None:
         raise Http404
     else:
         return region
开发者ID:j-barron,项目名称:zamboni,代码行数:6,代码来源:views.py


示例17: region_from_request

 def region_from_request(self, request):
     address = request.META.get('REMOTE_ADDR')
     ip_reg = self.geoip.lookup(address)
     log.info('Geodude lookup for {0} returned {1}'
              .format(address, ip_reg))
     return parse_region(ip_reg) or mkt.regions.RESTOFWORLD
开发者ID:JaredKerim-Mozilla,项目名称:zamboni,代码行数:6,代码来源:middleware.py


示例18: get_region

def get_region():
    """Get the region for the current request lifecycle."""
    return parse_region(getattr(_local, "region", "")) or RESTOFWORLD
开发者ID:gurumukhi,项目名称:zamboni,代码行数:3,代码来源:__init__.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python forms.ApiReviewersSearchForm类代码示例发布时间:2022-05-27
下一篇:
Python regions.get_region函数代码示例发布时间: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