Add support for GeoIP data (#3230)

This commit is contained in:
Raphael Michel
2023-04-17 09:50:46 +02:00
committed by GitHub
parent c890f4cdc0
commit 11e3bd4d39
10 changed files with 55 additions and 8 deletions

View File

@@ -45,7 +45,7 @@ from phonenumber_field.formfields import PhoneNumberField
from pretix.base.forms.questions import (
BaseInvoiceAddressForm, BaseQuestionsForm, WrappedPhoneNumberPrefixWidget,
guess_phone_prefix,
guess_phone_prefix_from_request,
)
from pretix.base.templatetags.rich_text import rich_text
from pretix.base.validators import EmailBanlistValidator
@@ -73,7 +73,7 @@ class ContactForm(forms.Form):
if self.event.settings.order_phone_asked:
if not self.initial.get('phone'):
phone_prefix = guess_phone_prefix(self.event)
phone_prefix = guess_phone_prefix_from_request(self.request, self.event)
if phone_prefix:
# We now exploit an implementation detail in PhoneNumberPrefixWidget to allow us to pass just
# a country code but no number as an initial value. It's a bit hacky, but should be stable for

View File

@@ -25,7 +25,8 @@ from django.utils.translation import gettext_lazy as _
from phonenumber_field.formfields import PhoneNumberField
from pretix.base.forms.questions import (
NamePartsFormField, WrappedPhoneNumberPrefixWidget, guess_phone_prefix,
NamePartsFormField, WrappedPhoneNumberPrefixWidget,
guess_phone_prefix_from_request,
)
from pretix.base.models import Quota, WaitingListEntry
from pretix.base.templatetags.rich_text import rich_text
@@ -40,6 +41,7 @@ class WaitingListForm(forms.ModelForm):
fields = ('name_parts', 'email', 'phone')
def __init__(self, *args, **kwargs):
request = kwargs.pop('request')
self.event = kwargs.pop('event')
self.channel = kwargs.pop('channel')
customer = kwargs.pop('customer')
@@ -93,7 +95,7 @@ class WaitingListForm(forms.ModelForm):
if event.settings.waiting_list_phones_asked:
if not self.initial.get('phone'):
phone_prefix = guess_phone_prefix(event)
phone_prefix = guess_phone_prefix_from_request(request, event)
if phone_prefix:
self.initial['phone'] = "+{}.".format(phone_prefix)