forked from CGM_Public/pretix_original
* 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
22 lines
626 B
Python
22 lines
626 B
Python
from django.core.files import File
|
|
from i18nfield.utils import I18nJSONEncoder
|
|
from phonenumber_field.phonenumber import PhoneNumber
|
|
|
|
from pretix.base.reldate import RelativeDateWrapper
|
|
|
|
|
|
class CustomJSONEncoder(I18nJSONEncoder):
|
|
def default(self, obj):
|
|
if isinstance(obj, RelativeDateWrapper):
|
|
return obj.to_string()
|
|
elif isinstance(obj, File):
|
|
return obj.name
|
|
if isinstance(obj, PhoneNumber):
|
|
return str(obj)
|
|
else:
|
|
return super().default(obj)
|
|
|
|
|
|
def safe_string(original):
|
|
return original.replace("<", "\\u003C").replace(">", "\\u003E")
|