mirror of
https://github.com/pretix/pretix.git
synced 2026-05-05 15:14:04 +00:00
Allow to set privacy policy URL per language (#3146)
This commit is contained in:
@@ -36,11 +36,13 @@ import logging
|
||||
|
||||
import i18nfield.forms
|
||||
from django import forms
|
||||
from django.core.validators import URLValidator
|
||||
from django.forms.models import ModelFormMetaclass
|
||||
from django.utils.crypto import get_random_string
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
from formtools.wizard.views import SessionWizardView
|
||||
from hierarkey.forms import HierarkeyForm
|
||||
from i18nfield.strings import LazyI18nString
|
||||
|
||||
from pretix.base.reldate import RelativeDateField, RelativeDateTimeField
|
||||
|
||||
@@ -222,3 +224,17 @@ class SecretKeySettingsField(forms.CharField):
|
||||
if value == SECRET_REDACTED:
|
||||
return
|
||||
return super().run_validators(value)
|
||||
|
||||
|
||||
class I18nURLFormField(i18nfield.forms.I18nFormField):
|
||||
def clean(self, value) -> LazyI18nString:
|
||||
value = super().clean(value)
|
||||
if not value:
|
||||
return value
|
||||
if isinstance(value.data, dict):
|
||||
for v in value.data.values():
|
||||
if v:
|
||||
URLValidator()(v)
|
||||
else:
|
||||
URLValidator()(value.data)
|
||||
return value
|
||||
|
||||
Reference in New Issue
Block a user