Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Get rid of PhonePrefixWidget
Patryk Zawadzki31b1870d0c62
diff --git a/saleor/account/i18n.py b/saleor/account/i18n.pyindex e9745160be..9d0581fa96 100644--- a/saleor/account/i18n.py+++ b/saleor/account/i18n.py@@ -8,7 +8,7 @@ from django_countries import countriesfrom .models import Addressfrom .validators import validate_possible_number-from .widgets import DatalistTextWidget, PhonePrefixWidget+from .widgets import DatalistTextWidgetCOUNTRY_FORMS = {}UNKNOWN_COUNTRIES = set()@@ -107,7 +107,7 @@ class AddressForm(forms.ModelForm):"street_address_2": "Apartment, suite, unit, building, floor, etc",}- phone = PossiblePhoneNumberFormField(widget=PhonePrefixWidget, required=False)+ phone = PossiblePhoneNumberFormField(required=False)def __init__(self, *args, **kwargs):autocomplete_type = kwargs.pop("autocomplete_type", None)diff --git a/saleor/account/widgets.py b/saleor/account/widgets.pyindex 5d544267e2..8f3dbf2777 100644--- a/saleor/account/widgets.py+++ b/saleor/account/widgets.py@@ -1,32 +1,4 @@-from django.forms import Select, TextInput-from phonenumber_field.widgets import PhoneNumberPrefixWidget-from phonenumbers import COUNTRY_CODE_TO_REGION_CODE--phone_prefixes = [- ("+{}".format(k), "+{}".format(k))- for (k, v) in sorted(COUNTRY_CODE_TO_REGION_CODE.items())-]---class PhonePrefixWidget(PhoneNumberPrefixWidget):- """Uses choices with tuple in a simple form of "+XYZ: +XYZ".-- Workaround for an issue:- https://github.com/stefanfoulis/django-phonenumber-field/issues/82- """-- def __init__(self, attrs=None):- widgets = (Select(attrs=attrs, choices=phone_prefixes), TextInput())- # pylint: disable=bad-super-call- super(PhoneNumberPrefixWidget, self).__init__(widgets, attrs)-- def value_from_datadict(self, data, files, name):- value = super().value_from_datadict(data, files, name)- # FIXME: this is a hack, we should not be using a multiwidget- # in forms used by the API but here we are- if not value and name in data:- value = data[name]- return value+from django.forms import Selectclass DatalistTextWidget(Select):