From 59c09e27fdc794b1910109cfb71b47febd90c7f2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Jan 2026 17:31:39 +0100 Subject: [PATCH] Update django-phonenumber-field requirement from ==7.3.* to ==8.3.* (#5522) * Update django-phonenumber-field requirement from ==7.3.* to ==8.3.* Updates the requirements on [django-phonenumber-field](https://github.com/stefanfoulis/django-phonenumber-field) to permit the latest version. - [Release notes](https://github.com/stefanfoulis/django-phonenumber-field/releases) - [Changelog](https://github.com/stefanfoulis/django-phonenumber-field/blob/main/CHANGELOG.rst) - [Commits](https://github.com/stefanfoulis/django-phonenumber-field/compare/7.3.0...8.3.0) --- updated-dependencies: - dependency-name: django-phonenumber-field dependency-version: 8.3.0 dependency-type: direct:production ... Signed-off-by: dependabot[bot] * Remove invalid geo codes --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Raphael Michel --- pyproject.toml | 2 +- src/pretix/base/forms/questions.py | 14 ++++++++++---- src/pretix/helpers/countries.py | 8 ++++++-- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 01392a1f01..7b66f45b08 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,7 +51,7 @@ dependencies = [ "django-markup", "django-oauth-toolkit==2.3.*", "django-otp==1.6.*", - "django-phonenumber-field==7.3.*", + "django-phonenumber-field==8.3.*", "django-redis==6.0.*", "django-scopes==2.0.*", "django-statici18n==2.6.*", diff --git a/src/pretix/base/forms/questions.py b/src/pretix/base/forms/questions.py index 7d810e3e84..e991084e04 100644 --- a/src/pretix/base/forms/questions.py +++ b/src/pretix/base/forms/questions.py @@ -66,8 +66,10 @@ from geoip2.errors import AddressNotFoundError from phonenumber_field.formfields import PhoneNumberField from phonenumber_field.phonenumber import PhoneNumber from phonenumber_field.widgets import PhoneNumberPrefixWidget -from phonenumbers import NumberParseException, national_significant_number -from phonenumbers.data import _COUNTRY_CODE_TO_REGION_CODE +from phonenumbers import ( + COUNTRY_CODE_TO_REGION_CODE, REGION_CODE_FOR_NON_GEO_ENTITY, + NumberParseException, national_significant_number, +) from PIL import ImageOps from pretix.base.forms.widgets import ( @@ -305,7 +307,9 @@ class WrappedPhonePrefixSelect(Select): choices = [("", "---------")] if initial: - for prefix, values in _COUNTRY_CODE_TO_REGION_CODE.items(): + for prefix, values in COUNTRY_CODE_TO_REGION_CODE.items(): + if all(v == REGION_CODE_FOR_NON_GEO_ENTITY for v in values): + continue if initial in values: self.initial = "+%d" % prefix break @@ -437,7 +441,9 @@ def guess_phone_prefix_from_request(request, event): def get_phone_prefix(country): - for prefix, values in _COUNTRY_CODE_TO_REGION_CODE.items(): + if country == REGION_CODE_FOR_NON_GEO_ENTITY: + return None + for prefix, values in COUNTRY_CODE_TO_REGION_CODE.items(): if country in values: return prefix return None diff --git a/src/pretix/helpers/countries.py b/src/pretix/helpers/countries.py index 9cd4c944b1..eeae03bd51 100644 --- a/src/pretix/helpers/countries.py +++ b/src/pretix/helpers/countries.py @@ -25,7 +25,9 @@ from django.utils import translation from django.utils.translation import gettext_noop from django_countries import Countries, collator from django_countries.fields import CountryField -from phonenumbers.data import _COUNTRY_CODE_TO_REGION_CODE +from phonenumbers import ( + COUNTRY_CODE_TO_REGION_CODE, REGION_CODE_FOR_NON_GEO_ENTITY, +) from pretix.base.i18n import get_babel_locale, get_language_without_region @@ -109,9 +111,11 @@ def get_phone_prefixes_sorted_and_localized(): val = [] locale = Locale(translation.to_locale(language)) - for prefix, values in _COUNTRY_CODE_TO_REGION_CODE.items(): + for prefix, values in COUNTRY_CODE_TO_REGION_CODE.items(): prefix = "+%d" % prefix for country_code in values: + if country_code == REGION_CODE_FOR_NON_GEO_ENTITY: + continue country_name = locale.territories.get(country_code) if country_name: val.append((prefix, "{} {}".format(country_name, prefix)))