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


Python data.COUNTRIES类代码示例

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


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

示例1: scoreboard

def scoreboard(request):
    if not request.user.is_authenticated():
        return HttpResponseRedirect(reverse('login'))

    categories = QuestionCategory.objects.all()
    countries = COUNTRIES.items()
    country = request.POST['country'] if request.POST.has_key('country') else None
    category = request.POST['cat_id'] if request.POST.has_key('cat_id') else None
    selected_country = country.split('\'')[1] if country else None
    quizs = Quiz.objects.all()
    if category:
        quizs = quizs.filter(category__id=category)
    scores = {}
    for q in quizs:
        if q.competitor1.user.first_name in scores:
            scores[q.competitor1.user.first_name] = scores[q.competitor1.user.first_name]+(q.score1 or 0)
        else:
            if q.competitor1.nationality.code == selected_country or not selected_country:
                scores[q.competitor1.user.first_name] = (q.score1 or 0)

        if q.competitor2.user.first_name in scores:
            scores[q.competitor2.user.first_name] = scores[q.competitor2.user.first_name]+(q.score2 or 0)
        else:
            if q.competitor2.nationality.code == selected_country or not selected_country:
                scores[q.competitor2.user.first_name] = (q.score2 or 0)
    scores = sorted(scores.items(), key=operator.itemgetter(1), reverse=True)[:5]
    return render_to_response('quiz/scoreboard.html', {'cats':categories, 'category':int(category) if category else category, 'countries':countries, 'selected_country':selected_country, 'scores':scores}, context_instance=RequestContext(request))
开发者ID:MMoein,项目名称:quizup,代码行数:27,代码来源:views.py

示例2: country_response

 def country_response(self):
     from django_countries.data import COUNTRIES
     countries = sorted(list(COUNTRIES.items()), key=lambda x: x[1].encode('utf-8'))
     if self.search_string:
         search_string = self.search_string.lower()
         return [x for x in countries if x[1].lower().startswith(search_string)]
     return countries
开发者ID:dimagi,项目名称:commcare-hq,代码行数:7,代码来源:async_handlers.py

示例3: check_ioc_countries

def check_ioc_countries():
    """
    Check if all IOC codes map to ISO codes correctly
    """
    from django_countries.data import COUNTRIES

    print("Checking if all IOC codes map correctly")
    for key in ISO_TO_IOC:
        assert COUNTRIES.get(key), 'No ISO code for %s' % key
    print("Finished checking IOC codes")
开发者ID:DjangoAdminHackers,项目名称:django-countries,代码行数:10,代码来源:ioc_data.py

示例4: check_ioc_countries

def check_ioc_countries(verbosity=1):
    """
    Check if all IOC codes map to ISO codes correctly
    """
    from django_countries.data import COUNTRIES

    if verbosity:  # pragma: no cover
        print("Checking if all IOC codes map correctly")
    for key in ISO_TO_IOC:
        assert COUNTRIES.get(key), "No ISO code for %s" % key
    if verbosity:  # pragma: no cover
        print("Finished checking IOC codes")
开发者ID:SmileyChris,项目名称:django-countries,代码行数:12,代码来源:ioc_data.py

示例5: __init__

    def __init__(self, account, domain, creating_user, data=None, *args, **kwargs):
        super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs)
        self.fields["confirm_product_agreement"].label = _(
            'I have read and agree to the <a href="%(pa_url)s" target="_blank">'
            "Software Product Subscription Agreement</a>."
        ) % {"pa_url": reverse("product_agreement")}

        from corehq.apps.users.views.mobile import MobileWorkerListView

        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Basic Information"),
                "company_name",
                "first_name",
                "last_name",
                crispy.Field("emails", css_class="input-xxlarge"),
                "phone_number",
            ),
            crispy.Fieldset(
                _("Mailing Address"),
                "first_line",
                "second_line",
                "city",
                "state_province_region",
                "postal_code",
                crispy.Field(
                    "country", css_class="input-large", data_countryname=COUNTRIES.get(self.current_country, "")
                ),
            ),
            crispy.Field("confirm_product_agreement"),
            FormActions(
                crispy.HTML(
                    '<a href="%(user_list_url)s" class="btn">%(text)s</a>'
                    % {
                        "user_list_url": reverse(MobileWorkerListView.urlname, args=[self.domain]),
                        "text": _("Back to Mobile Workers List"),
                    }
                ),
                StrictButton(
                    _("Confirm Billing Information"),
                    type="submit",
                    css_class="btn btn-primary disabled",
                    disabled="disabled",
                    css_id="submit-button-pa",
                ),
                crispy.HTML(
                    '<p class="help-inline" id="submit-button-help-qa" style="vertical-align: '
                    'top; margin-top: 5px; margin-bottom: 0px;">%s</p>'
                    % _("Please agree to the Product Subscription " "Agreement above before continuing.")
                ),
            ),
        )
开发者ID:bazuzi,项目名称:commcare-hq,代码行数:52,代码来源:forms.py

示例6: countries

    def countries(self):
        """
        Return the countries list, modified by any overriding settings.
        The result is cached so future lookups are less work intensive.
        """
        # Local import so that countries aren't loaded into memory until first
        # used.
        from django_countries.data import COUNTRIES

        if not hasattr(self, '_countries'):
            self._countries = []
            overrides = settings.COUNTRIES_OVERRIDE
            for code, name in COUNTRIES.items():
                if code in overrides:
                    name = overrides['code']
                if name:
                    self.countries.append((code, name))
        return self._countries
开发者ID:Sureiya,项目名称:django-countries,代码行数:18,代码来源:__init__.py

示例7: update_mozillian_profiles

def update_mozillian_profiles(queryset=None):
    """Sync MozillianProfile objects with mozillians.org"""

    if not queryset:
        queryset = MozillianProfile.objects.all()

    for mozillian in queryset:
        data = get_mozillian_by_email(mozillian.email)

        if not data:
            # Try to fetch by username
            data = get_mozillian_by_username(mozillian.mozillian_username)

            if not data:
                continue

        if 'country' in data:
            mozillian.country = COUNTRIES.get(data['country'].upper(), '').capitalize()
        if 'full_name' in data:
            mozillian.full_name = data['full_name']
        else:
            mozillian.full_name = 'Private Mozillian'
        mozillian.email = data['email']
        if 'city' in data:
            mozillian.city = data['city']
        if 'ircname' in data:
            mozillian.ircname = data['ircname']
        if 'photo' in data:
            mozillian.avatar_url = data['photo']
        if 'bio' in data:
            mozillian.bio = data['bio']
        mozillian.save()

        mozillian.tracking_groups.clear()
        groups = []
        if 'groups' in data:
            for group in data['groups']:
                obj, created = MozillianGroup.objects.get_or_create(name=group)
                groups.append(obj)

        mozillian.tracking_groups = groups
        logger.debug('Mozillian succesfully updated.')
开发者ID:akatsoulas,项目名称:woodstock,代码行数:42,代码来源:utils.py

示例8: __init__

    def __init__(self, account, domain, creating_user, data=None, *args, **kwargs):
        super(ConfirmExtraUserChargesForm, self).__init__(account, domain, creating_user, data=data, *args, **kwargs)

        from corehq.apps.users.views.mobile import MobileWorkerListView
        self.helper.label_class = 'col-sm-3 col-md-2'
        self.helper.field_class = 'col-sm-9 col-md-8 col-lg-6'
        self.helper.layout = crispy.Layout(
            crispy.Fieldset(
                _("Basic Information"),
                'company_name',
                'first_name',
                'last_name',
                crispy.Field('email_list', css_class='input-xxlarge accounting-email-select2',
                             data_initial=json.dumps(self.initial.get('email_list'))),
                'phone_number',
            ),
            crispy.Fieldset(
                 _("Mailing Address"),
                'first_line',
                'second_line',
                'city',
                'state_province_region',
                'postal_code',
                crispy.Field('country', css_class="input-large accounting-country-select2",
                             data_country_code=self.current_country or '',
                             data_country_name=COUNTRIES.get(self.current_country, '')),
            ),
            hqcrispy.FormActions(
                crispy.HTML(
                    '<a href="%(user_list_url)s" class="btn btn-default">%(text)s</a>' % {
                        'user_list_url': reverse(MobileWorkerListView.urlname, args=[self.domain]),
                        'text': _("Back to Mobile Workers List")
                    }
                ),
                StrictButton(
                    _("Confirm Billing Information"),
                    type="submit",
                    css_class='btn btn-primary disabled',
                ),
            ),
        )
开发者ID:dimagi,项目名称:commcare-hq,代码行数:41,代码来源:forms.py

示例9: handle

    def handle(self, *args, **options):
        print "Migrating Domain countries"

        country_lookup = {v.lower(): k for k, v in COUNTRIES.iteritems()}
        #Special cases
        country_lookup["USA"] = country_lookup["united states"]
        country_lookup["California"] = country_lookup["united states"]
        country_lookup["Wales"] = country_lookup["united kingdom"]

        for domain in Domain.get_all():
            if domain.deployment._doc.get('countries', None):
                continue
            try:
                country = None
                if domain.deployment._doc.get('country', None):
                    country = domain.deployment._doc['country']
                elif domain._doc.get('country', None):
                    country = domain._doc['country']

                if country:
                    if ',' in country:
                        countries = country.split(',')
                    elif ' and ' in country:
                        countries = country.split(' and ')
                    else:
                        countries = [country]

                    abbr = []
                    for country in countries:
                        country = country.strip().lower()
                        if country in country_lookup.keys():
                            abbr.append(country_lookup[country])

                    domain.deployment.countries = abbr
                    domain.save()
            except Exception as e:
                print "There was an error migrating the domain named %s." % domain.name
                print "Error: %s" % e
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:38,代码来源:migrate_domain_countries.py

示例10: forwards

    def forwards(self, orm):
        reverse_map = dict((v.upper(), k) for k, v in COUNTRIES.items())
        # add a few special cases to the list that we know might exist
        reverse_map['GREAT BRITAIN'] = 'GB'
        reverse_map['KOREA'] = 'KR'
        reverse_map['MACEDONIA'] = 'MK'
        reverse_map['RUSSIA'] = 'RU'
        reverse_map['SOUTH KOREA'] = 'KR'
        reverse_map['TAIWAN'] = 'TW'
        reverse_map['VIETNAM'] = 'VN'

        for country_name in orm.Mirror.objects.values_list(
                'country_old', flat=True).order_by().distinct():
            code = reverse_map.get(country_name.upper(), '')
            orm.Mirror.objects.filter(
                    country_old=country_name).update(country=code)

        for country_name in orm.MirrorUrl.objects.filter(
				country_old__isnull=False).values_list(
                'country_old', flat=True).order_by().distinct():
            code = reverse_map.get(country_name.upper(), '')
            orm.MirrorUrl.objects.filter(
                    country_old=country_name).update(country=code)
开发者ID:Saren-Arterius,项目名称:archweb,代码行数:23,代码来源:0015_assign_country_codes.py

示例11: country_response

 def country_response(self):
     from django_countries.data import COUNTRIES
     countries = sorted(COUNTRIES.items(), key=lambda x: x[1].encode('utf-8'))
     if self.search_string:
         return filter(lambda x: x[1].lower().startswith(self.search_string.lower()), countries)
     return countries
开发者ID:puttarajubr,项目名称:commcare-hq,代码行数:6,代码来源:async_handlers.py

示例12: _get_country

def _get_country(domain):
    project = Domain.get_by_name(domain)
    if project and project.deployment.countries:
        return unicode(COUNTRIES.get(project.deployment.countries[0], ''))
开发者ID:bazuzi,项目名称:commcare-hq,代码行数:4,代码来源:run_form_websocket_feed.py

示例13: dict

from .image_generator import generate_image

DEFAULT_IDENTIFIER = "default"
DEFAULT_NAME = "Default"

DEFAULT_ADDRESS_DATA = dict(
    prefix="Sir",
    name=u"Dog Hello",
    suffix=", Esq.",
    postal_code="K9N",
    street="Woof Ave.",
    city="Dog Fort",
    country="GB"
)

COUNTRY_CODES = sorted(COUNTRIES.keys())


class FuzzyBoolean(fuzzy.BaseFuzzyAttribute):
    def __init__(self, probability, **kwargs):
        self.probability = probability
        super(FuzzyBoolean, self).__init__()

    def fuzz(self):
        return (random.random() < self.probability)


class UserFactory(DjangoModelFactory):
    class Meta:
        model = settings.AUTH_USER_MODEL
开发者ID:US365,项目名称:shoop,代码行数:30,代码来源:factories.py

示例14: country_name_from_isd_code_or_empty

def country_name_from_isd_code_or_empty(isd_code):
    cc = COUNTRY_CODE_TO_REGION_CODE.get(isd_code)
    return force_unicode(COUNTRIES.get(cc[0])) if cc else ''
开发者ID:ansarbek,项目名称:commcare-hq,代码行数:3,代码来源:utils.py

示例15: construct_address_form


def construct_address_form(country_code, i18n_rules):
    class_name = 'AddressForm%s' % country_code
    base_class = CountryAwareAddressForm
    form_kwargs = {
        'Meta': type(str('Meta'), (base_class.Meta, object), {}),
        'formfield_callback': None}
    class_ = type(base_class)(str(class_name), (base_class, ), form_kwargs)
    update_base_fields(class_, i18n_rules)
    class_.i18n_country_code = country_code
    class_.i18n_fields_order = property(get_form_i18n_lines)
    return class_


for country in COUNTRIES.keys():
    try:
        country_rules = i18naddress.get_validation_rules(
            {'country_code': country})
    except ValueError:
        country_rules = i18naddress.get_validation_rules({})
        UNKNOWN_COUNTRIES.add(country)

COUNTRY_CHOICES = [(code, label) for code, label in COUNTRIES.items()
                   if code not in UNKNOWN_COUNTRIES]
# Sort choices list by country name
COUNTRY_CHOICES = sorted(COUNTRY_CHOICES, key=lambda choice: choice[1])

for country, label in COUNTRY_CHOICES:
    country_rules = i18naddress.get_validation_rules({'country_code': country})
    COUNTRY_FORMS[country] = construct_address_form(country, country_rules)
开发者ID:elwoodxblues,项目名称:saleor,代码行数:29,代码来源:i18n.py


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