diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5bd037e66c71a6baa21feac768315f57f4d78482..936b6ddc110a9a1a1810b1c829e1d1ade4c1b3e4 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -9,6 +9,11 @@ and this project adheres to `Semantic Versioning`_. Unreleased ---------- +Added +~~~~~ + +* Add preference for configuring the default phone number country code. + Fixed ~~~~~ diff --git a/aleksis/core/preferences.py b/aleksis/core/preferences.py index afd38c9658e605a91e67f5cb25379186f3feb3bc..cb351100a5da31c4d5cffc2255542bc86f4a77c1 100644 --- a/aleksis/core/preferences.py +++ b/aleksis/core/preferences.py @@ -3,6 +3,7 @@ from django.forms import EmailField, ImageField, URLField from django.forms.widgets import SelectMultiple from django.utils.translation import gettext_lazy as _ +import pycountry from colorfield.widgets import ColorWidget from dynamic_preferences.preferences import Section from dynamic_preferences.types import ( @@ -431,3 +432,13 @@ class AutoUpdatingDashboardSite(BooleanPreference): name = "automatically_update_dashboard_site" default = True verbose_name = _("Automatically update the dashboard and its widgets sitewide") + + +@site_preferences_registry.register +class PhoneNumberCountry(ChoicePreference): + section = internationalisation + name = "phone_number_country" + required = True + default = "GB" + choices = [(x.alpha_2, x.alpha_2) for x in pycountry.countries] + verbose_name = _("Country for phone number parsing") diff --git a/pyproject.toml b/pyproject.toml index dc1f7c074cc9551187dc37513f4d68549b7b0452..309044a7c8e9a1fb05858ea8e9ea6c7e0b8edb27 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -117,6 +117,7 @@ haystack-redis = "^0.0.1" python-gnupg = "^0.4.7" sentry-sdk = {version = "^1.4.3", optional = true} django-cte = "^1.1.5" +pycountry = "^20.7.3" [tool.poetry.extras] ldap = ["django-auth-ldap"]