当前位置: 首页>>代码示例>>Python>>正文


Python utils.parse_region函数代码示例

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


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


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