Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions pretix_withdrawal/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,25 @@
pass


class HoneypotField(forms.URLField):
default_error_messages = {"invalid": _("Leave this field empty.")}

def __init__(self, **kwargs):
kwargs["required"] = False
kwargs.setdefault("help_text", _("Leave this field empty."))
super().__init__(**kwargs)

def clean(self, value):
cleaned = super().clean(value)
if cleaned:
raise ValidationError(self.error_messages["invalid"])


class CreateForm(I18nModelForm):
required_css_class = "required"

url = HoneypotField()
Comment thread
pajowu marked this conversation as resolved.
Resolved

class Meta:
model = Withdrawal
fields = ("email", "name", "order_code", "message")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ <h2>{{ headline }}</h2>
{% bootstrap_field form.email layout="checkout" %}
{% bootstrap_field form.order_code layout="checkout" %}
{% bootstrap_field form.message layout="checkout" %}
{% bootstrap_field form.url layout="checkout" form_group_class="form-group hidden" %}
Comment thread
pajowu marked this conversation as resolved.
Resolved
</div>
</div>
<div class="row">
Expand Down
Loading