mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Increase length of multiple-choice country fields
This commit is contained in:
@@ -33,6 +33,15 @@ class CachedCountries(Countries):
|
||||
class FastCountryField(CountryField):
|
||||
def __init__(self, *args, **kwargs):
|
||||
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)
|
||||
|
||||
def check(self, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user