1056 lines
35 KiB
Python
1056 lines
35 KiB
Python
from django.conf import settings
|
||
from django.core.files import File
|
||
from wagtail.models import Page
|
||
|
||
|
||
def find_available_slug(requested_slug, ignore_page_id=None):
|
||
"""
|
||
Finds an available slug within the specified parent.
|
||
|
||
If the requested slug is not available, this adds a number on the end, for example:
|
||
|
||
- 'requested-slug'
|
||
- 'requested-slug-1'
|
||
- 'requested-slug-2'
|
||
|
||
And so on, until an available slug is found.
|
||
|
||
The `ignore_page_id` keyword argument is useful for when you are updating a page,
|
||
you can pass the page being updated here so the page's current slug is not
|
||
treated as in use by another page.
|
||
"""
|
||
|
||
pages = Page.objects.filter(slug__startswith=requested_slug)
|
||
|
||
if ignore_page_id:
|
||
pages = pages.exclude(id=ignore_page_id)
|
||
|
||
existing_slugs = set(pages.values_list("slug", flat=True))
|
||
slug = requested_slug
|
||
number = 1
|
||
|
||
while slug in existing_slugs:
|
||
slug = requested_slug + "-" + str(number)
|
||
number += 1
|
||
|
||
return slug
|
||
|
||
|
||
orgs = {
|
||
1: {"de": "andere Broker", "fr": "autres Broker", "it": "altre Broker"},
|
||
2: {
|
||
"de": "andere Krankenversicherer",
|
||
"fr": "autres assureurs santé",
|
||
"it": "altre assicurazioni sanitarie",
|
||
},
|
||
3: {
|
||
"de": "andere Privatversicherer",
|
||
"fr": "autres Assurance privée",
|
||
"it": "altre Assicurazione privato",
|
||
},
|
||
4: {"de": "Allianz Suisse", "fr": "Allianz Suisse", "it": "Allianz Suisse"},
|
||
5: {"de": "AON", "fr": "AON", "it": "AON"},
|
||
6: {
|
||
"de": "AXA Winterthur",
|
||
"fr": "AXA Assurances SA",
|
||
"it": "AXA Assicurazioni SA",
|
||
},
|
||
7: {"de": "Baloise", "fr": "Baloise", "it": "Baloise"},
|
||
8: {
|
||
"de": "CAP Rechtsschutz",
|
||
"fr": "CAP Protection juridique",
|
||
"it": "CAP Protezione giuridica",
|
||
},
|
||
9: {
|
||
"de": "Coop Rechtsschutz",
|
||
"fr": "Coop Protection juridique",
|
||
"it": "Coop Protezione giuridica",
|
||
},
|
||
10: {"de": "CSS", "fr": "CSS", "it": "CSS"},
|
||
11: {"de": "Die Mobiliar", "fr": "La Mobilière", "it": "La Mobiliare"},
|
||
12: {
|
||
"de": "Emmental Versicherung",
|
||
"fr": "Emmental Assurance",
|
||
"it": "Emmental Assicurazione",
|
||
},
|
||
13: {
|
||
"de": "GENERALI Versicherungen",
|
||
"fr": "Generali Assurances",
|
||
"it": "Generali Assicurazioni",
|
||
},
|
||
14: {"de": "Groupe Mutuel", "fr": "GROUPE MUTUEL", "it": "GROUPE MUTUEL"},
|
||
15: {"de": "Helsana", "fr": "Helsana", "it": "Helsana"},
|
||
16: {"de": "Helvetia", "fr": "Helvetia", "it": "Helvetia"},
|
||
17: {"de": "Kessler & Co AG", "fr": "Kessler & Co AG", "it": "Kessler & Co AG"},
|
||
18: {
|
||
"de": "Orion Rechtsschutz Versicherung",
|
||
"fr": "Orion Protection juridique",
|
||
"it": "Orion Protezione giuridica",
|
||
},
|
||
19: {"de": "PAX", "fr": "PAX", "it": "PAX"},
|
||
20: {"de": "Sanitas", "fr": "Sanitas", "it": "Sanitas"},
|
||
21: {"de": "SUVA", "fr": "SUVA", "it": "SUVA"},
|
||
22: {"de": "Swica", "fr": "Swica", "it": "Swica"},
|
||
23: {"de": "Swiss Life", "fr": "Swiss Life", "it": "Swiss Life"},
|
||
24: {"de": "Swiss Re", "fr": "Swiss Re", "it": "Swiss Re"},
|
||
25: {
|
||
"de": "Visana Services AG",
|
||
"fr": "Visana Services SA",
|
||
"it": "Visana Services SA",
|
||
},
|
||
26: {
|
||
"de": "VZ VermögensZentrum AG",
|
||
"fr": "VZ VermögensZentrum AG",
|
||
"it": "VZ VermögensZentrum AG",
|
||
},
|
||
27: {
|
||
"de": "Würth Financial Services AG",
|
||
"fr": "Würth Financial Services SA",
|
||
"it": "Würth Financial Services SA",
|
||
},
|
||
28: {"de": "Zürich", "fr": "Zurich", "it": "Zurigo"},
|
||
29: {"de": "VBV", "fr": "AFA", "it": "AFA"},
|
||
30: {"de": "Vaudoise", "fr": "Vaudoise", "it": "Vaudoise"},
|
||
31: {
|
||
"de": "Keine Firmenzugehörigkeit",
|
||
"fr": "Pas d'appartenance à une entreprise",
|
||
"it": "Nessuna affiliazione aziendale",
|
||
},
|
||
}
|
||
|
||
|
||
def add_organisations(apps=None, schema_editor=None):
|
||
if apps is None:
|
||
# pylint: disable=import-outside-toplevel
|
||
from vbv_lernwelt.core.models import Organisation
|
||
else:
|
||
Organisation = apps.get_model("core", "Organisation")
|
||
|
||
for org_id, org_data in orgs.items():
|
||
Organisation.objects.get_or_create(
|
||
organisation_id=org_id,
|
||
name_de=org_data["de"],
|
||
name_fr=org_data["fr"],
|
||
name_it=org_data["it"],
|
||
)
|
||
|
||
|
||
def remove_organisations(apps=None, schema_editor=None):
|
||
if apps is None:
|
||
# pylint: disable=import-outside-toplevel
|
||
from vbv_lernwelt.core.models import Organisation
|
||
else:
|
||
Organisation = apps.get_model("core", "Organisation")
|
||
|
||
for org_id in orgs.keys():
|
||
Organisation.objects.filter(
|
||
organisation_id=org_id,
|
||
).delete()
|
||
|
||
|
||
def migrate_avatars(apps=None, schema_editor=None):
|
||
# pylint: disable=import-outside-toplevel
|
||
if apps is None:
|
||
from vbv_lernwelt.core.models import User
|
||
from vbv_lernwelt.media_files.models import UserImage
|
||
else:
|
||
User = apps.get_model("core", "User")
|
||
UserImage = apps.get_model("media_files", "UserImage")
|
||
|
||
# Models created by Django migration don't contain methods of the parent model.
|
||
# We need to add them manually.
|
||
from wagtail.images.models import AbstractImage
|
||
|
||
UserImage.get_upload_to = AbstractImage.get_upload_to
|
||
|
||
avatar_dir = settings.APPS_DIR / "static" / "avatars"
|
||
|
||
for user in User.objects.all().exclude(
|
||
avatar_url="/static/avatars/myvbv-default-avatar.png"
|
||
):
|
||
if not user.avatar_url:
|
||
continue
|
||
|
||
avatar_file = user.avatar_url.split("/")[-1]
|
||
|
||
try:
|
||
with open(avatar_dir / avatar_file, "rb") as f:
|
||
image = UserImage.objects.create(
|
||
file=File(f),
|
||
)
|
||
user.avatar = image
|
||
user.save()
|
||
except FileNotFoundError:
|
||
pass
|
||
|
||
|
||
countries = {
|
||
1: {
|
||
"de": "Afghanistan",
|
||
"fr": "Afghanistan",
|
||
"it": "Afghanistan",
|
||
"country_code": "AF",
|
||
},
|
||
2: {"de": "Albanien", "fr": "Albanie", "it": "Albania", "country_code": "AL"},
|
||
3: {"de": "Algerien", "fr": "Algérie", "it": "Algeria", "country_code": "DZ"},
|
||
5: {"de": "Andorra", "fr": "Andorra", "it": "Andorra", "country_code": "AD"},
|
||
6: {"de": "Angola", "fr": "Angola", "it": "Angola", "country_code": "AO"},
|
||
9: {
|
||
"de": "Antigua und Barbuda",
|
||
"fr": "Antigua et Barbuda",
|
||
"it": "Antigua e Barbuda",
|
||
"country_code": "AG",
|
||
},
|
||
10: {
|
||
"de": "Argentinien",
|
||
"fr": "Argentine",
|
||
"it": "Argentina",
|
||
"country_code": "AR",
|
||
},
|
||
11: {"de": "Armenien", "fr": "Armenia", "it": "Armenia", "country_code": "AM"},
|
||
13: {
|
||
"de": "Australien",
|
||
"fr": "Australie",
|
||
"it": "Australia",
|
||
"country_code": "AU",
|
||
},
|
||
14: {
|
||
"de": "Österreich",
|
||
"fr": "Autriche",
|
||
"it": "Austria",
|
||
"country_code": "AT",
|
||
"order_id": 4.0,
|
||
},
|
||
15: {
|
||
"de": "Aserbaidschan",
|
||
"fr": "Azerbaïdjan",
|
||
"it": "Azerbaijan",
|
||
"country_code": "AZ",
|
||
},
|
||
16: {"de": "Bahamas", "fr": "Bahamas", "it": "Bahamas", "country_code": "BS"},
|
||
17: {"de": "Bahrain", "fr": "Bahrain", "it": "Bahrain", "country_code": "BH"},
|
||
18: {
|
||
"de": "Bangladesh",
|
||
"fr": "Bangladesh",
|
||
"it": "Bangladesh",
|
||
"country_code": "BD",
|
||
},
|
||
19: {"de": "Barbados", "fr": "Barbados", "it": "Barbados", "country_code": "BB"},
|
||
20: {"de": "Belarus", "fr": "Belarus", "it": "Belarus", "country_code": "BY"},
|
||
21: {"de": "Belgien", "fr": "Belgique", "it": "Belgio", "country_code": "BE"},
|
||
22: {"de": "Belize", "fr": "Belize", "it": "Belize", "country_code": "BZ"},
|
||
23: {"de": "Benin", "fr": "Benin", "it": "Benin", "country_code": "BJ"},
|
||
25: {"de": "Bhutan", "fr": "Bhutan", "it": "Bhutan", "country_code": "BT"},
|
||
26: {"de": "Bolivien", "fr": "Bolivia", "it": "Bolivia", "country_code": "BO"},
|
||
27: {
|
||
"de": "Bosnien und Herzegowina",
|
||
"fr": "Bosnia et Herzegowina",
|
||
"it": "Bosnia e Herzegovina",
|
||
"country_code": "BA",
|
||
},
|
||
28: {"de": "Botswana", "fr": "Botswana", "it": "Botswana", "country_code": "BW"},
|
||
30: {"de": "Brasilien", "fr": "Brésil", "it": "Brasile", "country_code": "BR"},
|
||
32: {"de": "Brunei", "fr": "Brunei", "it": "Brunei", "country_code": "BN"},
|
||
33: {"de": "Bulgarien", "fr": "Bulgarie", "it": "Bulgaria", "country_code": "BG"},
|
||
34: {
|
||
"de": "Burkina Faso",
|
||
"fr": "Burkina Faso",
|
||
"it": "Burkina Faso",
|
||
"country_code": "BF",
|
||
},
|
||
35: {"de": "Burundi", "fr": "Burundi", "it": "Burundi", "country_code": "BI"},
|
||
36: {"de": "Kambodscha", "fr": "Cambodia", "it": "Cambogia", "country_code": "KH"},
|
||
37: {"de": "Kamerun", "fr": "Cameroon", "it": "Camerun", "country_code": "CM"},
|
||
38: {"de": "Kanada", "fr": "Canada", "it": "Canada", "country_code": "CA"},
|
||
39: {"de": "Kap Verde", "fr": "Cap Vert", "it": "Capo Verde", "country_code": "CV"},
|
||
41: {
|
||
"de": "Zentralafrikanische Republik",
|
||
"fr": "Centrafricaine (République)",
|
||
"it": "Repubblica Centrafricana",
|
||
"country_code": "CF",
|
||
},
|
||
42: {"de": "Tschad", "fr": "Tchad", "it": "Ciad", "country_code": "TD"},
|
||
43: {"de": "Chile", "fr": "Chile", "it": "Cile", "country_code": "CL"},
|
||
44: {
|
||
"de": "Volksrepublik China",
|
||
"fr": "Chine (Rép. pop.)",
|
||
"it": "Cina",
|
||
"country_code": "CN",
|
||
},
|
||
47: {"de": "Kolumbien", "fr": "Colombia", "it": "Colombia", "country_code": "CO"},
|
||
48: {"de": "Komoren", "fr": "Comoros", "it": "Comoros", "country_code": "KM"},
|
||
49: {
|
||
"de": "Kongo, Republik",
|
||
"fr": "Congo, Republic of the",
|
||
"it": "Congo, Repubblica del",
|
||
"country_code": "CG",
|
||
},
|
||
50: {
|
||
"de": "Kongo, Demokratische Republik",
|
||
"fr": "Congo, The Democratic Republic of the",
|
||
"it": "Congo, Repubblica Democratica del",
|
||
"country_code": "CD",
|
||
},
|
||
51: {"de": "Grenada", "fr": "Grenade", "it": "Grenada", "country_code": "GD"},
|
||
52: {
|
||
"de": "Costa Rica",
|
||
"fr": "Costa Rica",
|
||
"it": "Costa Rica",
|
||
"country_code": "CR",
|
||
},
|
||
53: {
|
||
"de": "Elfenbeinküste",
|
||
"fr": "Côte d´Ivoire",
|
||
"it": "Costa d´Avorio",
|
||
"country_code": "CI",
|
||
},
|
||
54: {"de": "Kroatien", "fr": "Croatia", "it": "Croazia", "country_code": "HR"},
|
||
55: {"de": "Kuba", "fr": "Cuba", "it": "Cuba", "country_code": "CU"},
|
||
56: {"de": "Zypern", "fr": "Cyprus", "it": "Cipro", "country_code": "CY"},
|
||
57: {
|
||
"de": "Tschechische Republik",
|
||
"fr": "Czech Rebublic",
|
||
"it": "Repubblica Ceca",
|
||
"country_code": "CZ",
|
||
},
|
||
58: {"de": "Dänemark", "fr": "Danemark", "it": "Danimarca", "country_code": "DK"},
|
||
59: {"de": "Dschibuti", "fr": "Djibouti", "it": "Gibuti", "country_code": "DJ"},
|
||
60: {"de": "Dominica", "fr": "Dominique", "it": "Dominica", "country_code": "DM"},
|
||
61: {
|
||
"de": "Dominikanische Republik",
|
||
"fr": "République Dominicaine",
|
||
"it": "Repubblica Dominicana",
|
||
"country_code": "DO",
|
||
},
|
||
62: {
|
||
"de": "Ost Timor",
|
||
"fr": "Timor Oriental",
|
||
"it": "Timor Est",
|
||
"country_code": "TL",
|
||
},
|
||
63: {"de": "Ecuador", "fr": "Équateur", "it": "Ecuador", "country_code": "EC"},
|
||
64: {"de": "Ägypten", "fr": "Égyptien", "it": "Egitto", "country_code": "EG"},
|
||
65: {
|
||
"de": "El Salvador",
|
||
"fr": "Salvador",
|
||
"it": "El Salvador",
|
||
"country_code": "SV",
|
||
},
|
||
66: {
|
||
"de": "Äquatorialguniea",
|
||
"fr": "Guinée équatoriale",
|
||
"it": "Guinea Equatoriale",
|
||
"country_code": "GQ",
|
||
},
|
||
67: {"de": "Eritrea", "fr": "Érythrée", "it": "Eritrea", "country_code": "ER"},
|
||
68: {"de": "Estland", "fr": "Estonia", "it": "Estonia", "country_code": "EE"},
|
||
69: {"de": "Äthiopien", "fr": "Éthiopie", "it": "Etiopia", "country_code": "ET"},
|
||
72: {
|
||
"de": "Fidschi-Inseln",
|
||
"fr": "Iles Fidji",
|
||
"it": "Isole Figi",
|
||
"country_code": "FJ",
|
||
},
|
||
73: {"de": "Finnland", "fr": "Finlande", "it": "Finlandia", "country_code": "FI"},
|
||
74: {
|
||
"de": "Frankreich",
|
||
"fr": "France",
|
||
"it": "Francia",
|
||
"country_code": "FR",
|
||
"order_id": 5.0,
|
||
},
|
||
79: {"de": "Gabun", "fr": "Gabon", "it": "Gabon", "country_code": "GA"},
|
||
80: {"de": "Gambia", "fr": "Gambie", "it": "Gambia", "country_code": "GM"},
|
||
81: {"de": "Georgien", "fr": "Géorgie", "it": "Georgia", "country_code": "GE"},
|
||
82: {
|
||
"de": "Deutschland",
|
||
"fr": "Allemagne",
|
||
"it": "Germania",
|
||
"country_code": "DE",
|
||
"order_id": 2.0,
|
||
},
|
||
83: {"de": "Ghana", "fr": "Ghana", "it": "Ghana", "country_code": "GH"},
|
||
85: {"de": "Griechenland", "fr": "Grèce", "it": "Grecia", "country_code": "GR"},
|
||
90: {"de": "Guatemala", "fr": "Guatemala", "it": "Guatemala", "country_code": "GT"},
|
||
92: {"de": "Guinea", "fr": "Guinée", "it": "Guinea", "country_code": "GN"},
|
||
93: {
|
||
"de": "Guinea-Bissau",
|
||
"fr": "Guinée-Bissau",
|
||
"it": "Guinea-Bissau",
|
||
"country_code": "GW",
|
||
},
|
||
94: {"de": "Guyana", "fr": "Guyana", "it": "Guyana", "country_code": "GY"},
|
||
95: {"de": "Haiti", "fr": "Haïti", "it": "Haiti", "country_code": "HT"},
|
||
97: {"de": "Honduras", "fr": "Honduras", "it": "Honduras", "country_code": "HN"},
|
||
99: {"de": "Ungarn", "fr": "Hongrie", "it": "Ungheria", "country_code": "HU"},
|
||
100: {"de": "Island", "fr": "Icelande", "it": "Islanda", "country_code": "IS"},
|
||
101: {"de": "Indien", "fr": "India", "it": "India", "country_code": "IN"},
|
||
102: {
|
||
"de": "Indonesien",
|
||
"fr": "Indonésie",
|
||
"it": "Indonesia",
|
||
"country_code": "ID",
|
||
},
|
||
103: {"de": "Iran", "fr": "Iran", "it": "Iran", "country_code": "IR"},
|
||
104: {"de": "Irak", "fr": "Irak", "it": "Iraq", "country_code": "IQ"},
|
||
105: {"de": "Irland", "fr": "Irlande", "it": "Irlanda", "country_code": "IE"},
|
||
107: {"de": "Israel", "fr": "Israël", "it": "Israele", "country_code": "IL"},
|
||
108: {
|
||
"de": "Italien",
|
||
"fr": "Italie",
|
||
"it": "Italia",
|
||
"country_code": "IT",
|
||
"order_id": 6.0,
|
||
},
|
||
109: {"de": "Jamaika", "fr": "Jamaïque", "it": "Giamaica", "country_code": "JM"},
|
||
110: {"de": "Japan", "fr": "Japon", "it": "Giappone", "country_code": "JP"},
|
||
112: {"de": "Jordanien", "fr": "Jordanie", "it": "Giordania", "country_code": "JO"},
|
||
113: {
|
||
"de": "Kasachstan",
|
||
"fr": "Kazakstan",
|
||
"it": "Kazakistan",
|
||
"country_code": "KZ",
|
||
},
|
||
114: {"de": "Kenia", "fr": "Kénia", "it": "Kenia", "country_code": "KE"},
|
||
115: {"de": "Kiribati", "fr": "Kiribati", "it": "Kiribati", "country_code": "KI"},
|
||
116: {
|
||
"de": "Korea, Demokratische Volksrepublik",
|
||
"fr": "Corée du Nord",
|
||
"it": "Corea, Repubblica Popolare Democratica",
|
||
"country_code": "KP",
|
||
},
|
||
117: {
|
||
"de": "Korea, Republik (auch: Südkorea)",
|
||
"fr": "Corée du Sud",
|
||
"it": "Corea, Repubblica (anche: Corea del Sud)",
|
||
"country_code": "KR",
|
||
},
|
||
118: {"de": "Kuwait", "fr": "Koweït", "it": "Kuwait", "country_code": "KW"},
|
||
119: {
|
||
"de": "Kirgisistan",
|
||
"fr": "Kirgistan",
|
||
"it": "Kirghizistan",
|
||
"country_code": "KG",
|
||
},
|
||
120: {"de": "Laos", "fr": "Laos", "it": "Laos", "country_code": "LA"},
|
||
121: {"de": "Lettland", "fr": "Lettonie", "it": "Lettonia", "country_code": "LV"},
|
||
122: {"de": "Libanon", "fr": "Lebanon", "it": "Libano", "country_code": "LB"},
|
||
123: {"de": "Lesotho", "fr": "Lesotho", "it": "Lesotho", "country_code": "LS"},
|
||
124: {"de": "Liberia", "fr": "Liberia", "it": "Liberia", "country_code": "LR"},
|
||
125: {"de": "Libyen", "fr": "Libye", "it": "Libia", "country_code": "LY"},
|
||
126: {
|
||
"de": "Liechtenstein",
|
||
"fr": "Liechtenstein",
|
||
"it": "Liechtenstein",
|
||
"country_code": "LI",
|
||
"order_id": 3.0,
|
||
},
|
||
127: {"de": "Litauen", "fr": "Lituanie", "it": "Lituania", "country_code": "LT"},
|
||
128: {
|
||
"de": "Luxembourg",
|
||
"fr": "Luxembourg",
|
||
"it": "Lussemburgo",
|
||
"country_code": "LU",
|
||
},
|
||
130: {
|
||
"de": "Nordmazedonien",
|
||
"fr": "Macédoine du Nord",
|
||
"it": "Macedonia del Nord",
|
||
"country_code": "MK",
|
||
},
|
||
131: {
|
||
"de": "Madagaskar",
|
||
"fr": "Madagascar",
|
||
"it": "Madagascar",
|
||
"country_code": "MG",
|
||
},
|
||
132: {"de": "Malawi", "fr": "Malawi", "it": "Malawi", "country_code": "MW"},
|
||
133: {"de": "Malaysia", "fr": "Malaisie", "it": "Malesia", "country_code": "MY"},
|
||
134: {"de": "Malediven", "fr": "Maldives", "it": "Maldive", "country_code": "MV"},
|
||
135: {"de": "Mali", "fr": "Mali", "it": "Mali", "country_code": "ML"},
|
||
136: {"de": "Malta", "fr": "Malte", "it": "Malta", "country_code": "MT"},
|
||
137: {
|
||
"de": "Marshall Inseln",
|
||
"fr": "Iles Marshall",
|
||
"it": "Isole Marshall",
|
||
"country_code": "MH",
|
||
},
|
||
139: {
|
||
"de": "Mauretanien",
|
||
"fr": "Mauritanie",
|
||
"it": "Mauritania",
|
||
"country_code": "MR",
|
||
},
|
||
140: {
|
||
"de": "Mauritius",
|
||
"fr": "Ile Maurice",
|
||
"it": "Mauritius",
|
||
"country_code": "MU",
|
||
},
|
||
142: {"de": "Mexico", "fr": "Mexique", "it": "Messico", "country_code": "MX"},
|
||
143: {
|
||
"de": "Mikronesien",
|
||
"fr": "Micronésie",
|
||
"it": "Micronesia",
|
||
"country_code": "FM",
|
||
},
|
||
144: {"de": "Moldavien", "fr": "Moldavie", "it": "Moldova", "country_code": "MD"},
|
||
145: {"de": "Monaco", "fr": "Monaco", "it": "Monaco", "country_code": "MC"},
|
||
146: {"de": "Mongolei", "fr": "Mongolie", "it": "Mongolia", "country_code": "MN"},
|
||
148: {"de": "Marokko", "fr": "Morocco", "it": "Marocco", "country_code": "MA"},
|
||
149: {
|
||
"de": "Mosambik",
|
||
"fr": "Mozambique",
|
||
"it": "Mozambico",
|
||
"country_code": "MZ",
|
||
},
|
||
150: {"de": "Myanmar", "fr": "Myanmar", "it": "Myanmar", "country_code": "MM"},
|
||
151: {"de": "Namibia", "fr": "Namibie", "it": "Namibia", "country_code": "NA"},
|
||
152: {"de": "Nauru", "fr": "Nauru", "it": "Nauru", "country_code": "NR"},
|
||
153: {"de": "Nepal", "fr": "Népal", "it": "Nepal", "country_code": "NP"},
|
||
154: {
|
||
"de": "Niederlande",
|
||
"fr": "Pays-Bas",
|
||
"it": "Paesi Bassi",
|
||
"country_code": "NL",
|
||
},
|
||
157: {
|
||
"de": "Neuseeland",
|
||
"fr": "Nouvelle-Zélande",
|
||
"it": "Nuova Zelanda",
|
||
"country_code": "NZ",
|
||
},
|
||
158: {
|
||
"de": "Nicaragua",
|
||
"fr": "Nicaragua",
|
||
"it": "Nicaragua",
|
||
"country_code": "NI",
|
||
},
|
||
159: {"de": "Niger", "fr": "Niger", "it": "Niger", "country_code": "NE"},
|
||
160: {"de": "Nigeria", "fr": "Nigeria", "it": "Nigeria", "country_code": "NG"},
|
||
164: {"de": "Norwegen", "fr": "Norvège", "it": "Norvegia", "country_code": "NO"},
|
||
165: {"de": "Oman", "fr": "Oman", "it": "Oman", "country_code": "OM"},
|
||
166: {"de": "Pakistan", "fr": "Pakistan", "it": "Pakistan", "country_code": "PK"},
|
||
167: {"de": "Palau", "fr": "Palau", "it": "Palau", "country_code": "PW"},
|
||
168: {"de": "Panama", "fr": "Panama", "it": "Panama", "country_code": "PA"},
|
||
170: {
|
||
"de": "Papua-Neuguinea",
|
||
"fr": "Papouasie Nouvelle-Guinée",
|
||
"it": "Papua Nuova Guinea",
|
||
"country_code": "PG",
|
||
},
|
||
171: {"de": "Paraguay", "fr": "Paraguay", "it": "Paraguay", "country_code": "PY"},
|
||
172: {"de": "Peru", "fr": "Pérou", "it": "Perù", "country_code": "PE"},
|
||
173: {
|
||
"de": "Philippinen",
|
||
"fr": "Philippines",
|
||
"it": "Filippine",
|
||
"country_code": "PH",
|
||
},
|
||
175: {"de": "Polen", "fr": "Pologne", "it": "Polonia", "country_code": "PL"},
|
||
176: {"de": "Portugal", "fr": "Portugal", "it": "Portogallo", "country_code": "PT"},
|
||
178: {"de": "Katar", "fr": "Qatar", "it": "Qatar", "country_code": "QA"},
|
||
180: {"de": "Rumänien", "fr": "Roumanie", "it": "Romania", "country_code": "RO"},
|
||
181: {
|
||
"de": "Russische Föderation",
|
||
"fr": "Russie",
|
||
"it": "Russia",
|
||
"country_code": "RU",
|
||
},
|
||
182: {"de": "Ruanda", "fr": "Ruanda", "it": "Ruanda", "country_code": "RW"},
|
||
183: {
|
||
"de": "Saint Kitts und Nevis",
|
||
"fr": "Saint-Kitts-et-Nevis",
|
||
"it": "Saint Kitts e Nevis",
|
||
"country_code": "KN",
|
||
},
|
||
184: {
|
||
"de": "St. Lucia",
|
||
"fr": "Sainte-Lucie",
|
||
"it": "Santa Lucia",
|
||
"country_code": "LC",
|
||
},
|
||
185: {
|
||
"de": "St. Vincent und die Grenadinen",
|
||
"fr": "Saint-Vincent-et-Les Grenadines",
|
||
"it": "Saint Vincent e Grenadine",
|
||
"country_code": "VC",
|
||
},
|
||
186: {"de": "Samoa", "fr": "Samoa", "it": "Samoa", "country_code": "WS"},
|
||
187: {
|
||
"de": "San Marino",
|
||
"fr": "San Marino",
|
||
"it": "San Marino",
|
||
"country_code": "SM",
|
||
},
|
||
188: {
|
||
"de": "Sao Tome und Principe",
|
||
"fr": "Sao Tomé-et-Principe",
|
||
"it": "São Tomé e Principe",
|
||
"country_code": "ST",
|
||
},
|
||
189: {
|
||
"de": "Saudi-Arabien",
|
||
"fr": "Arabie Saoudite",
|
||
"it": "Arabia Saudita",
|
||
"country_code": "SA",
|
||
},
|
||
190: {"de": "Senegal", "fr": "Sénégal", "it": "Senegal", "country_code": "SN"},
|
||
191: {
|
||
"de": "Seychellen",
|
||
"fr": "Seychelles",
|
||
"it": "Seychelles",
|
||
"country_code": "SC",
|
||
},
|
||
192: {
|
||
"de": "Sierra Leone",
|
||
"fr": "Sierra Leone",
|
||
"it": "Sierra Leone",
|
||
"country_code": "SL",
|
||
},
|
||
193: {"de": "Singapur", "fr": "Singapour", "it": "Singapore", "country_code": "SG"},
|
||
194: {
|
||
"de": "Slowakei",
|
||
"fr": "Slovaquie",
|
||
"it": "Slovacchia",
|
||
"country_code": "SK",
|
||
},
|
||
195: {"de": "Slowenien", "fr": "Slovénie", "it": "Slovenia", "country_code": "SI"},
|
||
196: {
|
||
"de": "Salomonen",
|
||
"fr": "Iles Salomon",
|
||
"it": "Salomone",
|
||
"country_code": "SB",
|
||
},
|
||
197: {"de": "Somalia", "fr": "Somalie", "it": "Somalia", "country_code": "SO"},
|
||
198: {
|
||
"de": "Südafrika",
|
||
"fr": "Afrique du Sud",
|
||
"it": "Africa del Sud",
|
||
"country_code": "ZA",
|
||
},
|
||
200: {"de": "Spanien", "fr": "Espagne", "it": "Spagna", "country_code": "ES"},
|
||
201: {
|
||
"de": "Sri Lanka",
|
||
"fr": "Sri Lanka",
|
||
"it": "Sri Lanka",
|
||
"country_code": "LK",
|
||
},
|
||
204: {"de": "Sudan", "fr": "Soudan", "it": "Sudan", "country_code": "SD"},
|
||
205: {"de": "Suriname", "fr": "Suriname", "it": "Suriname", "country_code": "SR"},
|
||
207: {
|
||
"de": "Swasiland",
|
||
"fr": "Swaziland",
|
||
"it": "Swaziland",
|
||
"country_code": "SZ",
|
||
},
|
||
208: {"de": "Schweden", "fr": "Suède", "it": "Svezia", "country_code": "SE"},
|
||
209: {
|
||
"de": "Schweiz",
|
||
"fr": "Suisse",
|
||
"it": "Svizzera",
|
||
"country_code": "CH",
|
||
"order_id": 1.0,
|
||
},
|
||
210: {"de": "Syrien", "fr": "Syrie", "it": "Siria", "country_code": "SY"},
|
||
211: {"de": "Taiwan", "fr": "Taïwan", "it": "Taiwan", "country_code": "TW"},
|
||
212: {
|
||
"de": "Tadschikistan",
|
||
"fr": "Tadjikistan",
|
||
"it": "Tagikistan",
|
||
"country_code": "TJ",
|
||
},
|
||
213: {"de": "Tansania", "fr": "Tanzanie", "it": "Tanzania", "country_code": "TZ"},
|
||
214: {"de": "Thailand", "fr": "Thaïlande", "it": "Tailandia", "country_code": "TH"},
|
||
215: {"de": "Togo", "fr": "Togo", "it": "Togo", "country_code": "TG"},
|
||
217: {"de": "Tonga", "fr": "Tonga", "it": "Tonga", "country_code": "TO"},
|
||
218: {
|
||
"de": "Trinidad und Tobago",
|
||
"fr": "Trinité-et-Tobago",
|
||
"it": "Trinidad e Tobago",
|
||
"country_code": "TT",
|
||
},
|
||
219: {"de": "Tunesien", "fr": "Tunisie", "it": "Tunisia", "country_code": "TN"},
|
||
220: {"de": "Türkei", "fr": "Turchia", "it": "Turchia", "country_code": "TR"},
|
||
221: {
|
||
"de": "Turkmenistan",
|
||
"fr": "Turkménistan",
|
||
"it": "Turkmenistan",
|
||
"country_code": "TM",
|
||
},
|
||
223: {"de": "Tuvalu", "fr": "Tuvalu", "it": "Tuvalu", "country_code": "TV"},
|
||
224: {"de": "Uganda", "fr": "Ouganda", "it": "Uganda", "country_code": "UG"},
|
||
225: {"de": "Ukraine", "fr": "Ukraine", "it": "Ucraina", "country_code": "UA"},
|
||
226: {
|
||
"de": "Vereinigte Arabische Emirate",
|
||
"fr": "Émirats Arabes Unis",
|
||
"it": "Emirati Arabi Uniti",
|
||
"country_code": "AE",
|
||
},
|
||
227: {
|
||
"de": "Großbritannien",
|
||
"fr": "Royaume-Uni",
|
||
"it": "Regno Unito",
|
||
"country_code": "GB",
|
||
},
|
||
228: {
|
||
"de": "USA",
|
||
"fr": "États-Unis",
|
||
"it": "Stati Uniti d´ America",
|
||
"country_code": "US",
|
||
},
|
||
230: {"de": "Uruguay", "fr": "Uruguay", "it": "Uruguay", "country_code": "UY"},
|
||
231: {
|
||
"de": "Usbekistan",
|
||
"fr": "Ouzbékistan",
|
||
"it": "Uzbekistan",
|
||
"country_code": "UZ",
|
||
},
|
||
232: {"de": "Vanuatu", "fr": "Vanuatu", "it": "Vanuatu", "country_code": "VU"},
|
||
233: {
|
||
"de": "Vatikanstadt",
|
||
"fr": "Vatican",
|
||
"it": "Città del Vaticano",
|
||
"country_code": "VA",
|
||
},
|
||
234: {
|
||
"de": "Venezuela",
|
||
"fr": "Venezuela",
|
||
"it": "Venezuela",
|
||
"country_code": "VE",
|
||
},
|
||
235: {"de": "Vietnam", "fr": "Viêtnam", "it": "Vietnam", "country_code": "VN"},
|
||
239: {"de": "Sahara", "fr": "Sahara", "it": "Sahara", "country_code": "EH"},
|
||
240: {"de": "Jemen", "fr": "Yémen", "it": "Yemen", "country_code": "YE"},
|
||
241: {"de": "Serbien", "fr": "Serbie", "it": "Serbia", "country_code": "RS"},
|
||
242: {
|
||
"de": "Montenegro",
|
||
"fr": "Monténégro",
|
||
"it": "Montenegro",
|
||
"country_code": "ME",
|
||
},
|
||
243: {"de": "Sambia", "fr": "Zambie", "it": "Zambia", "country_code": "ZM"},
|
||
244: {"de": "Simbabwe", "fr": "Zimbabwe", "it": "Zimbabwe", "country_code": "ZW"},
|
||
245: {
|
||
"de": "Hong Kong",
|
||
"fr": "Hong Kong",
|
||
"it": "Hong Kong",
|
||
"country_code": "HK",
|
||
},
|
||
246: {
|
||
"de": "Falkland Inseln",
|
||
"fr": "Îles Malouines",
|
||
"it": "Isole Falkland",
|
||
"country_code": "FK",
|
||
},
|
||
247: {"de": "Aruba", "fr": "Aruba", "it": "Aruba", "country_code": "AW"},
|
||
248: {"de": "Bermuda", "fr": "Bermudes", "it": "Bermuda", "country_code": "BM"},
|
||
249: {
|
||
"de": "Britische Jungferninseln",
|
||
"fr": "Îles Vierges britanniques",
|
||
"it": "Isole Vergini britanniche",
|
||
"country_code": "VG",
|
||
},
|
||
250: {"de": "Curaçao", "fr": "Curaçao", "it": "Curaçao", "country_code": "CW"},
|
||
251: {"de": "Anguilla", "fr": "Anguilla", "it": "Anguilla", "country_code": "AI"},
|
||
252: {
|
||
"de": "Montserrat",
|
||
"fr": "Montserrat",
|
||
"it": "Montserrat",
|
||
"country_code": "MS",
|
||
},
|
||
253: {
|
||
"de": "Bonaire, Sint Eustatius und Saba",
|
||
"fr": "Bonaire, Saint-Eustache et Saba",
|
||
"it": "Bonaire, Sint Eustatius e Saba",
|
||
"country_code": "BQ",
|
||
},
|
||
254: {
|
||
"de": "Cayman Inseln",
|
||
"fr": "Îles Caïmans",
|
||
"it": "Isole Cayman",
|
||
"country_code": "KY",
|
||
},
|
||
255: {
|
||
"de": "Sint Maarten",
|
||
"fr": "Saint-Martin",
|
||
"it": "Sint Maarten",
|
||
"country_code": "SX",
|
||
},
|
||
256: {
|
||
"de": "Turks- und Caicos-Inseln",
|
||
"fr": "Îles Turks et Caïques",
|
||
"it": "Turks e Caicos",
|
||
"country_code": "TC",
|
||
},
|
||
257: {
|
||
"de": "Saint-Barth",
|
||
"fr": "Saint-Barthélemy",
|
||
"it": "Saint-Barth",
|
||
"country_code": "BL",
|
||
},
|
||
258: {
|
||
"de": "Palästinensisches Gebiet",
|
||
"fr": "Territoires palestiniens occupés",
|
||
"it": "Territori palestinesi",
|
||
"country_code": "PS",
|
||
},
|
||
259: {"de": "Kosovo", "fr": "Kosovo", "it": "Kosovo", "country_code": "XK"},
|
||
260: {
|
||
"de": "Gibraltar",
|
||
"fr": "Gibraltar",
|
||
"it": "Gibilterra",
|
||
"country_code": "GI",
|
||
},
|
||
261: {
|
||
"de": "Neukaledonien",
|
||
"fr": "Nouvelle-Calédonie",
|
||
"it": "Nuova Caledonia",
|
||
"country_code": "NC",
|
||
},
|
||
262: {
|
||
"de": "Französisch-Polynesien",
|
||
"fr": "Polynésie française",
|
||
"it": "Polinesia francese",
|
||
"country_code": "PF",
|
||
},
|
||
310: {
|
||
"de": "Niederländische Antillen",
|
||
"fr": "Antilles néerlandaises",
|
||
"it": "Antille olandesi",
|
||
"country_code": "AN",
|
||
},
|
||
311: {
|
||
"de": "Antarktika",
|
||
"fr": "Antarctique",
|
||
"it": "Antartide",
|
||
"country_code": "AQ",
|
||
},
|
||
312: {
|
||
"de": "Amerikanisch-Samoa",
|
||
"fr": "Samoa américaines",
|
||
"it": "Samoa americane",
|
||
"country_code": "AS",
|
||
},
|
||
313: {"de": "Åland", "fr": "Åland", "it": "Åland", "country_code": "AX"},
|
||
314: {
|
||
"de": "Bouvetinsel",
|
||
"fr": "Île Bouvet",
|
||
"it": "Isola Bouvet",
|
||
"country_code": "BV",
|
||
},
|
||
315: {
|
||
"de": "Kokosinseln",
|
||
"fr": "Îles Cocos",
|
||
"it": "Isole Cocos (Keeling)",
|
||
"country_code": "CC",
|
||
},
|
||
316: {
|
||
"de": "Cookinseln",
|
||
"fr": "Îles Cook",
|
||
"it": "Isole Cook",
|
||
"country_code": "CK",
|
||
},
|
||
317: {
|
||
"de": "Clipperton-Insel",
|
||
"fr": "Île de Clipperton",
|
||
"it": "Isola di Clipperton",
|
||
"country_code": "CP",
|
||
},
|
||
318: {
|
||
"de": "Weihnachtsinsel",
|
||
"fr": "Île Christmas",
|
||
"it": "Isola di Natale",
|
||
"country_code": "CX",
|
||
},
|
||
319: {
|
||
"de": "Färöer-Inseln",
|
||
"fr": "Îles Féroé",
|
||
"it": "Isole Färöer",
|
||
"country_code": "FO",
|
||
},
|
||
320: {
|
||
"de": "Französisch-Guayana",
|
||
"fr": "Guyane française",
|
||
"it": "Guyana francese",
|
||
"country_code": "GF",
|
||
},
|
||
321: {"de": "Guernsey", "fr": "Guernsey", "it": "Guernsey", "country_code": "GG"},
|
||
322: {
|
||
"de": "Grönland",
|
||
"fr": "Groenland",
|
||
"it": "Groenlandia",
|
||
"country_code": "GL",
|
||
},
|
||
323: {
|
||
"de": "Guadeloupe",
|
||
"fr": "Guadeloupe",
|
||
"it": "Guadalupa",
|
||
"country_code": "GP",
|
||
},
|
||
324: {
|
||
"de": "Südgeorgien und die Südlichen Sandwichinseln",
|
||
"fr": "Géorgie du Sud et Îles Sandwich du Sud",
|
||
"it": "Georgia del Sud e Sandwich Australi",
|
||
"country_code": "GS",
|
||
},
|
||
325: {"de": "Guam", "fr": "Guam", "it": "Guam", "country_code": "GU"},
|
||
326: {
|
||
"de": "Heard und McDonaldinseln",
|
||
"fr": "Îles Heard et McDonald",
|
||
"it": "Isola Heard e Isole McDonald",
|
||
"country_code": "HM",
|
||
},
|
||
327: {
|
||
"de": "Insel Man",
|
||
"fr": "Île de Man",
|
||
"it": "Isola di Man",
|
||
"country_code": "IM",
|
||
},
|
||
328: {
|
||
"de": "Britisches Territorium im Indischen Ozean",
|
||
"fr": "Territoire britannique de l´océan Indien",
|
||
"it": "Territori Britannici dell´Oceano Indiano",
|
||
"country_code": "IO",
|
||
},
|
||
329: {"de": "Jersey", "fr": "Jersey", "it": "Jersey", "country_code": "JE"},
|
||
330: {
|
||
"de": "Saint-Martin",
|
||
"fr": "Saint-Martin",
|
||
"it": "Saint Martin",
|
||
"country_code": "MF",
|
||
},
|
||
331: {"de": "Macau", "fr": "Macao", "it": "Macao", "country_code": "MO"},
|
||
332: {
|
||
"de": "Nördliche Marianen",
|
||
"fr": "Îles Mariannes du Nord",
|
||
"it": "Isole Marianne Settentrionali",
|
||
"country_code": "MP",
|
||
},
|
||
333: {
|
||
"de": "Martinique",
|
||
"fr": "Martinique",
|
||
"it": "Martinica",
|
||
"country_code": "MQ",
|
||
},
|
||
334: {
|
||
"de": "Norfolkinsel",
|
||
"fr": "Île Norfolk",
|
||
"it": "Isola Norfolk",
|
||
"country_code": "NF",
|
||
},
|
||
335: {"de": "Niue", "fr": "Niue", "it": "Niue", "country_code": "NU"},
|
||
336: {
|
||
"de": "Saint-Pierre und Miquelon",
|
||
"fr": "Saint-Pierre-et-Miquelon",
|
||
"it": "Saint-Pierre e Miquelon",
|
||
"country_code": "PM",
|
||
},
|
||
337: {
|
||
"de": "Pitcairninseln",
|
||
"fr": "Îles Pitcairn",
|
||
"it": "Isole Pitcairn",
|
||
"country_code": "PN",
|
||
},
|
||
338: {
|
||
"de": "Puerto Rico",
|
||
"fr": "Porto Rico",
|
||
"it": "Porto Rico",
|
||
"country_code": "PR",
|
||
},
|
||
339: {
|
||
"de": "La Réunion",
|
||
"fr": "La Réunion",
|
||
"it": "Isola della Riunione",
|
||
"country_code": "RE",
|
||
},
|
||
340: {
|
||
"de": "St. Helena, Ascension und Tristan da Cunha",
|
||
"fr": "Sainte-Hélène, Ascension et Tristan da Cunha",
|
||
"it": "Sant´Elena, Ascensione e Tristan da Cunha",
|
||
"country_code": "SH",
|
||
},
|
||
341: {
|
||
"de": "Spitzbergen, Jan Mayen",
|
||
"fr": "Spitzberg, Jan Mayen",
|
||
"it": "Svalbard e Jan Mayen",
|
||
"country_code": "SJ",
|
||
},
|
||
342: {
|
||
"de": "Südsudan",
|
||
"fr": "Sud-Soudan",
|
||
"it": "Sudan del Sud",
|
||
"country_code": "SS",
|
||
},
|
||
343: {
|
||
"de": "Französische Süd- und Antarktisgebiete",
|
||
"fr": "Terres australes et antarctiques françaises",
|
||
"it": "Territori australi e antartico francese",
|
||
"country_code": "TF",
|
||
},
|
||
344: {"de": "Tokelau", "fr": "Tokelau", "it": "Tokelau", "country_code": "TK"},
|
||
345: {
|
||
"de": "United States Minor Outlying Islands",
|
||
"fr": "Îles mineures éloignées des États-Unis",
|
||
"it": "Isole Minori Esterne degli Stati Uniti",
|
||
"country_code": "UM",
|
||
},
|
||
346: {
|
||
"de": "Amerikanische Jungferninseln",
|
||
"fr": "Îles Vierges américaines",
|
||
"it": "Isole Vergini Americane",
|
||
"country_code": "VI",
|
||
},
|
||
347: {
|
||
"de": "Wallis und Futuna",
|
||
"fr": "Wallis et Futuna",
|
||
"it": "Wallis e Futuna",
|
||
"country_code": "WF",
|
||
},
|
||
348: {"de": "Mayotte", "fr": "Mayotte", "it": "Mayotte", "country_code": "YT"},
|
||
}
|
||
|
||
|
||
def add_countries(apps=None, schema_editor=None):
|
||
if apps is None:
|
||
# pylint: disable=import-outside-toplevel
|
||
from vbv_lernwelt.core.models import Country
|
||
else:
|
||
Country = apps.get_model("core", "Country")
|
||
|
||
has_country_code = any(
|
||
field.name == "country_code" for field in Country._meta.get_fields()
|
||
)
|
||
|
||
for country_id, country_name in countries.items():
|
||
country_code = country_name["country_code"]
|
||
|
||
if has_country_code:
|
||
Country.objects.get_or_create(
|
||
country_code=country_code,
|
||
vbv_country_id=country_id,
|
||
name_de=country_name["de"],
|
||
name_fr=country_name["fr"],
|
||
name_it=country_name["it"],
|
||
order_id=country_name.get("order_id", 20.0),
|
||
)
|
||
else:
|
||
Country.objects.get_or_create(
|
||
country_id=country_id,
|
||
name_de=country_name["de"],
|
||
name_fr=country_name["fr"],
|
||
name_it=country_name["it"],
|
||
)
|
||
|
||
|
||
def remove_countries(apps=None, schema_editor=None):
|
||
if apps is None:
|
||
# pylint: disable=import-outside-toplevel
|
||
from vbv_lernwelt.core.models import Country
|
||
else:
|
||
Country = apps.get_model("core", "Country")
|
||
for country_id in countries.keys():
|
||
Country.objects.filter(
|
||
country_id=country_id,
|
||
).delete()
|