parent
da960f99af
commit
ea2b27c887
|
@ -1,6 +1,7 @@
|
||||||
"""forms for use in views"""
|
"""forms for use in views"""
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
|
from django.core.exceptions import ValidationError
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
|
|
||||||
|
@ -137,6 +138,17 @@ class ContactForm(forms.Form):
|
||||||
from_email = forms.EmailField(label="Email", max_length=200)
|
from_email = forms.EmailField(label="Email", max_length=200)
|
||||||
subject = forms.CharField(label="Subject", max_length=200)
|
subject = forms.CharField(label="Subject", max_length=200)
|
||||||
message = forms.CharField(widget=forms.Textarea)
|
message = forms.CharField(widget=forms.Textarea)
|
||||||
|
bot_check = forms.CharField(
|
||||||
|
label="What is usually stored in a library?",
|
||||||
|
max_length=10,
|
||||||
|
help_text="Checking that you are human"
|
||||||
|
)
|
||||||
|
|
||||||
|
def clean_bot_check(self):
|
||||||
|
"""validate the bot check"""
|
||||||
|
data = self.cleaned_data["bot_check"]
|
||||||
|
if data != "books":
|
||||||
|
raise ValidationError("Try again. Think of something with pages.")
|
||||||
|
|
||||||
|
|
||||||
class SubscribeViaMastodon(forms.Form):
|
class SubscribeViaMastodon(forms.Form):
|
||||||
|
|
|
@ -10,16 +10,10 @@
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="columns eight">
|
<div class="columns eight">
|
||||||
<label for="{{ form.from_email.id_for_label }}">Your email address:</label>
|
{{form}}
|
||||||
{% if errors %} {{ form.from_email.errors }} {% endif %}
|
<div>
|
||||||
{{form.from_email}}
|
<input class="button-primary u-pull-right" type="submit" value="Send!">
|
||||||
<label for="{{ form.subject.id_for_label }}">Subject:</label>
|
</div>
|
||||||
{% if errors %} {{ form.subject.errors }} {% endif %}
|
|
||||||
{{form.subject}}
|
|
||||||
{% if errors %} {{ form.message.errors }} {% endif %}
|
|
||||||
<label for="{{ form.message.id_for_label }}">Message:</label>
|
|
||||||
<textarea name="message" id="message" class="u-full-width"></textarea>
|
|
||||||
<input class="button-primary u-pull-right" type="submit" value="Register!">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in a new issue