Skip to content

Commit 3497f62

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 063d5d8 commit 3497f62

2 files changed

Lines changed: 13 additions & 20 deletions

File tree

README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ They will add a [honeypot enable/disable](./wagtail_honeypot/models.py#L13) fiel
4242
If you follow the official Wagtail docs for the [Form Builder](https://docs.wagtail.org/en/stable/reference/contrib/forms/index.html) your form should look something like this...
4343

4444
```python
45-
from wagtail_honeypot.models import (
46-
HoneypotFormMixin, HoneypotFormSubmissionMixin
47-
)
45+
from wagtail_honeypot.models import HoneypotFormMixin, HoneypotFormSubmissionMixin
46+
4847

4948
class FormField(AbstractFormField):
5049
page = ParentalKey("FormPage", related_name="form_fields")
5150

51+
5252
class FormPage(HoneypotFormMixin, HoneypotFormSubmissionMixin):
5353
intro = RichTextField(blank=True)
5454
thank_you_text = RichTextField(blank=True)
@@ -93,13 +93,13 @@ If you prefer you could add the honeypot field to the content_panels rather than
9393
```python
9494
# replace
9595
edit_handler = TabbedInterface(
96-
[
97-
ObjectList(content_panels, heading="Content"),
98-
ObjectList(honeypot_panels, heading="Honeypot"),
99-
ObjectList(Page.promote_panels, heading="Promote"),
100-
ObjectList(Page.settings_panels, heading="Settings", classname="settings"),
101-
]
102-
)
96+
[
97+
ObjectList(content_panels, heading="Content"),
98+
ObjectList(honeypot_panels, heading="Honeypot"),
99+
ObjectList(Page.promote_panels, heading="Promote"),
100+
ObjectList(Page.settings_panels, heading="Settings", classname="settings"),
101+
]
102+
)
103103

104104
# with
105105
content_panels = content_panels + honeypot_panels

docs/developer.md

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ You can change the time field name and/or the time interval by adding the follow
119119

120120
```python
121121
HONEYPOT_TIME_FIELD = "time-field-name"
122-
HONEYPOT_TIME_INTERVAL = 1 # seconds
122+
HONEYPOT_TIME_INTERVAL = 1 # seconds
123123
```
124124

125125
> The time field and checks a time interval between the form being displayed and submitted.
@@ -159,14 +159,8 @@ class HoneypotFormSubmissionMixin(AbstractEmailForm):
159159
score = []
160160
if honeypot_name_field in form.data and honeypot_time_field in form.data:
161161
score.append(form.data[honeypot_name_field] == "")
162-
score.append(
163-
self.time_diff(form.data[honeypot_time_field], honeypot_time_interval)
164-
)
165-
return (
166-
super().process_form_submission(form)
167-
if len(score) and all(score)
168-
else None
169-
)
162+
score.append(self.time_diff(form.data[honeypot_time_field], honeypot_time_interval))
163+
return super().process_form_submission(form) if len(score) and all(score) else None
170164

171165
@staticmethod
172166
def time_diff(value, interval):
@@ -180,5 +174,4 @@ class HoneypotFormSubmissionMixin(AbstractEmailForm):
180174

181175
class Meta:
182176
abstract = True
183-
184177
```

0 commit comments

Comments
 (0)