Add question type: phone number (#1462)

* Add Phonenumber-Field as to Questions

* Add setup requirements

* Add list of ask-during-checkin restricted question types and enforce it

* Fix requirements

* Fix crash using custom locales

* Re-format phone numbers when outputting to humans

* Initialize country code field with a guess for the customer's country

* Document TEL type in API docs
This commit is contained in:
Martin Gross
2019-11-13 12:52:07 +01:00
committed by Raphael Michel
parent 06a744ea2d
commit 54091b9721
10 changed files with 83 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
from django.core.files import File
from i18nfield.utils import I18nJSONEncoder
from phonenumber_field.phonenumber import PhoneNumber
from pretix.base.reldate import RelativeDateWrapper
@@ -10,6 +11,8 @@ class CustomJSONEncoder(I18nJSONEncoder):
return obj.to_string()
elif isinstance(obj, File):
return obj.name
if isinstance(obj, PhoneNumber):
return str(obj)
else:
return super().default(obj)