mirror of
https://github.com/pretix/pretix.git
synced 2026-05-06 15:24:02 +00:00
* Upgrade Django to 3.0 and other dependencies to recent versions * Fix otp version contsraint * Remove six dependency * Resolve some warnings * Fix failing tests * Update django-countries * Resolve all RemovedInDjango31Warnings in test suite * Run isort * Fix import * Update PostgreSQL version on travis
68 lines
1.3 KiB
Python
68 lines
1.3 KiB
Python
from django.conf import settings
|
|
from django.core.exceptions import ValidationError
|
|
from django.utils.deconstruct import deconstructible
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
|
|
class BanlistValidator:
|
|
|
|
banlist = []
|
|
|
|
def __call__(self, value):
|
|
# Validation logic
|
|
if value in self.banlist:
|
|
raise ValidationError(
|
|
_('This field has an invalid value: %(value)s.'),
|
|
code='invalid',
|
|
params={'value': value},
|
|
)
|
|
|
|
|
|
@deconstructible
|
|
class EventSlugBanlistValidator(BanlistValidator):
|
|
|
|
banlist = [
|
|
'download',
|
|
'healthcheck',
|
|
'locale',
|
|
'control',
|
|
'redirect',
|
|
'jsi18n',
|
|
'metrics',
|
|
'_global',
|
|
'__debug__',
|
|
'api',
|
|
'events',
|
|
'csp_report',
|
|
'widget',
|
|
]
|
|
|
|
|
|
@deconstructible
|
|
class OrganizerSlugBanlistValidator(BanlistValidator):
|
|
|
|
banlist = [
|
|
'download',
|
|
'healthcheck',
|
|
'locale',
|
|
'control',
|
|
'pretixdroid',
|
|
'redirect',
|
|
'jsi18n',
|
|
'metrics',
|
|
'_global',
|
|
'__debug__',
|
|
'about',
|
|
'api',
|
|
'csp_report',
|
|
'widget',
|
|
]
|
|
|
|
|
|
@deconstructible
|
|
class EmailBanlistValidator(BanlistValidator):
|
|
|
|
banlist = [
|
|
settings.PRETIX_EMAIL_NONE_VALUE,
|
|
]
|