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


Python django_countries.countries方法代码示例

本文整理汇总了Python中django_countries.countries方法的典型用法代码示例。如果您正苦于以下问题:Python django_countries.countries方法的具体用法?Python django_countries.countries怎么用?Python django_countries.countries使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在django_countries的用法示例。


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

示例1: handle_label

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def handle_label(self, country, **options):
        self.country = country.upper()
        if self.country == 'ALL':
            self.countries = sorted(set(
                Place.objects
                .filter(in_book=True, visibility__visible_in_book=True, checked=True)
                .values_list('country', flat=True)
            ))
            for country in self.countries[:8]:
                print(country)
                self.country = country
                self.make()
            return
        if self.country not in countries:
            raise CommandError("Unknown country: {}".format(self.country))
        self.make() 
开发者ID:tejoesperanto,项目名称:pasportaservo,代码行数:18,代码来源:base.py

示例2: list_pending_events

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def list_pending_events(request, country_code):
    """
    Display a list of pending events.
    """

    active_page = request.GET.get('page', '')

    if request.user.is_staff:
        event_list = get_pending_events(past=True)
        event_list = sorted(event_list, key=lambda a: a.country.code)
    else:
        event_list = get_pending_events(country_code=country_code, past=True)

    country_name = unicode(dict(countries)[country_code])

    return render_to_response(
        'pages/list_events.html', {
            'event_list': event_list,
            'status': 'pending',
            'country_code': country_code,
            'country_name': country_name,
            'active_page': active_page
        }, context_instance=RequestContext(request)) 
开发者ID:codeeu,项目名称:coding-events,代码行数:25,代码来源:events.py

示例3: get_ambassadors_for_countries

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def get_ambassadors_for_countries():
    ambassadors = get_ambassadors()
    countries_ambassadors = []
    # list countries minus two CUSTOM_COUNTRY_ENTRIES
    for code, name in list(countries)[2:]:
        readable_name = unicode(name)
        country_ambassadors = [ambassador for ambassador in ambassadors if ambassador.country == code]
        # load main ambassadors
        main_ambassadors = [ambassador for ambassador in country_ambassadors if ambassador.is_main_contact]
        # exclude main ambassadors
        supporting_ambassadors = [ambassador for ambassador in country_ambassadors if not ambassador.is_main_contact]
        countries_ambassadors.append(
            (code, readable_name, supporting_ambassadors, main_ambassadors, facebook(readable_name)))

    countries_ambassadors.sort(key=lambda country: country[1], reverse=False)

    return countries_ambassadors 
开发者ID:codeeu,项目名称:coding-events,代码行数:19,代码来源:user.py

示例4: add_countries

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def add_countries(self):
        self.stdout.write("Adding Countries...", ending="")
        for code, name in countries:
            Country.objects.update_or_create(code=code, defaults={"name": name})
        self.stdout.write("Done") 
开发者ID:mozilla,项目名称:normandy,代码行数:7,代码来源:initial_data.py

示例5: _get_country_property

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def _get_country_property(code, property_name):
    return six.text_type(getattr(countries, property_name)(code)) 
开发者ID:edx,项目名称:edx-analytics-data-api,代码行数:4,代码来源:country.py

示例6: list_approved_events

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def list_approved_events(request, country_code):
    """
    Display a list of approved events.
    """

    event_list = get_approved_events(country_code=country_code, past=True)

    country_name = unicode(dict(countries)[country_code])

    return render_to_response('pages/list_events.html', {
        'event_list': event_list,
        'status': 'approved',
        'country_code': country_code,
        'country_name': country_name
    }, context_instance=RequestContext(request)) 
开发者ID:codeeu,项目名称:coding-events,代码行数:17,代码来源:events.py

示例7: list_countries

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def list_countries():
    all_countries = []
    for code, name in list(countries):
        readable_name = unicode(name)
        all_countries.append((readable_name, code))
    all_countries.sort()
    return all_countries 
开发者ID:codeeu,项目名称:coding-events,代码行数:9,代码来源:event.py

示例8: list_active_countries

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def list_active_countries(with_past_events=False):
    """ List countries with at least an Event associated """
    start_year = 2014 if with_past_events else datetime.datetime.now().year
    events_countries = Event.objects.filter(
            start_date__gte=datetime.date(start_year, 1, 1),
            status='APPROVED'
        ).values_list('country').order_by().distinct()

    active_countries = [(unicode(name), code) for code, name in list(countries) if (code,) in events_countries]

    return active_countries 
开发者ID:codeeu,项目名称:coding-events,代码行数:13,代码来源:event.py

示例9:

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def \
        count_approved_events_for_country(past=True):
    """
    Count the number of approved events and score for each country
    """

    all_events = Event.objects.filter(status='APPROVED')

    country_count = []

    # not including the first two fake countries in the list
    for country in list(countries)[2:]:
        country_code = country[0]
        country_name = country[1]
        number_of_events = all_events.filter(
            country=country_code).filter(
            start_date__gte=datetime.date(
                datetime.datetime.now().year, 1, 1)).count()
        population = Country.objects.get(iso=country_code).population
        country_score = 0
        if number_of_events > 0 and population > 0 and population != "":
            country_score = 1. * number_of_events / population
        country_entry = {'country_code': country_code,
                         'country_name': country_name,
                         'events': number_of_events,
                         'score': country_score}
        if number_of_events > 0:
            country_count.append(country_entry)

    sorted_count = sorted(
        country_count,
        key=lambda k: k['score'],
        reverse=True)
    return sorted_count 
开发者ID:codeeu,项目名称:coding-events,代码行数:36,代码来源:event.py

示例10: get_country_pos

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def get_country_pos(item):
    """
    Return country position
    """
    pos = 1
    # not including the first two fake countries in the list
    for country in list(countries)[2:]:
        country_name = country[1]
        if item == country_name:
            break
        else:
            pos = pos + 1

    return pos 
开发者ID:codeeu,项目名称:coding-events,代码行数:16,代码来源:event.py

示例11: check_project_list

# 需要导入模块: import django_countries [as 别名]
# 或者: from django_countries import countries [as 别名]
def check_project_list(self, projects):
        """This verifies that the supplied list of projects
        and only these projects are visible on the page """

        rows = self.browser.find_elements_by_xpath(
            "//table[@id='DataTables_Table_0']/tbody/tr"
        )
        assert len(rows) == len(projects)
        for row in rows:
            onclick_items = row.get_attribute('onclick').split('/')
            project_slug = onclick_items[4]

            cells = row.find_elements_by_tag_name('td')
            actual_org_slug = onclick_items[2]
            try:
                img = cells[2].find_element_by_tag_name('img')
                actual_org_logo = img.get_attribute('src')
                actual_org_name = img.get_attribute('alt')
            except NoSuchElementException:
                actual_org_logo = None
                alt = cells[2].find_elements_by_class_name('org-name-alt')
                actual_org_name = alt[0].text
            actual_project_name = (
                cells[1].find_element_by_tag_name('h4').text
            )
            actual_project_description = (
                cells[1].find_element_by_tag_name('p').text
            )
            actual_country = cells[3].text

            target_project = None
            for project in projects:
                if project['slug'] == project_slug:
                    target_project = project
                    break
            assert target_project

            assert actual_org_slug == target_project['_org_slug']
            assert actual_org_name == target_project['_org_name']
            expected_org_logo = (
                target_project['_org_logo']
                if target_project['_org_logo']
                else None
            )
            assert actual_org_logo == expected_org_logo
            assert actual_project_name == target_project['name']
            assert actual_project_description == target_project['description']
            expected_country = (
                dict(countries)[target_project['country']]
                if target_project['country'] else ''
            )
            assert actual_country == expected_country

            # TODO Check also last updated column 
开发者ID:Cadasta,项目名称:cadasta-platform,代码行数:56,代码来源:ProjectList.py


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