def forwards(self, orm):
        reverse_map = dict((v, k) for k, v in OFFICIAL_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)
Пример #2
0
    TournamentForm,
    TournamentPlayerForm,
    EmailPlayersForm,
    TournamentRegistrationForm,
    TournamentNewsItemForm)

from .models import (
    TournamentPage,
    TournamentPlayer,
    NoTournamentSpotsException,
    TournamentNewsItem)

from .utils.pdga import PDGARanking


FLIPPED_COUNTRIES = dict([(x, y) for y, x in OFFICIAL_COUNTRIES.items()])


@login_required
@csrf_exempt
def ajax_player_action(request):
    t = request.tournament

    # User must be admin
    if not request.is_tournament_admin:
        raise Http404

    # We only accept POST requests
    if request.method != 'POST':
        raise Http404
Пример #3
0
 def country_name(self):
     return OFFICIAL_COUNTRIES.get(self.country_code, 'unknown').title()