forked from CGM_Public/pretix_original
Increase length of multiple-choice country fields
This commit is contained in:
@@ -33,6 +33,15 @@ class CachedCountries(Countries):
|
|||||||
class FastCountryField(CountryField):
|
class FastCountryField(CountryField):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
kwargs.setdefault("countries", CachedCountries)
|
kwargs.setdefault("countries", CachedCountries)
|
||||||
|
|
||||||
|
if "max_length" not in kwargs:
|
||||||
|
# Override logic from CountryField to include 20% buffer. We don't want to migrate our database
|
||||||
|
# every time a new country is added to the system!
|
||||||
|
if kwargs.get("multiple", False):
|
||||||
|
kwargs["max_length"] = int(len(kwargs['countries']()) * 3 * 1.2)
|
||||||
|
else:
|
||||||
|
kwargs["max_length"] = 2
|
||||||
|
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
def check(self, **kwargs):
|
def check(self, **kwargs):
|
||||||
|
|||||||
Reference in New Issue
Block a user