Various fixes #7

Merged
hughrun merged 3 commits from fixes into main 2024-03-23 16:26:43 +11:00
3 changed files with 21 additions and 14 deletions

View file

@ -1,6 +1,7 @@
"""forms for use in views"""
from django import forms
from django.core.exceptions import ValidationError
from django.utils import timezone
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)
subject = forms.CharField(label="Subject", max_length=200)
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):

View file

@ -14,6 +14,8 @@ from django.utils import timezone as django_timezone
from blogs import models
from django.forms.models import model_to_dict
agent = "AusGLAMR/1.0 +https://ausglamr.newcardigan.org"
@ -165,7 +167,6 @@ class Command(BaseCommand):
newish = instance.pubdate > cutoff
if newish:
instance.announce()
blog.set_success(
updateddate=date_to_tz_aware(article.updated_parsed)
)

View file

@ -10,16 +10,10 @@
<div class="row">
<div class="columns eight">
<label for="{{ form.from_email.id_for_label }}">Your email address:</label>
{% if errors %} {{ form.from_email.errors }} {% endif %}
{{form.from_email}}
<label for="{{ form.subject.id_for_label }}">Subject:</label>
{% 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!">
{{form}}
<div>
<input class="button-primary u-pull-right" type="submit" value="Send!">
</div>
</div>
</div>
</form>