From 920d8833c14bab9bd34710c8283c2d8570950de7 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 23 Mar 2024 16:01:52 +1100 Subject: [PATCH 1/2] move set_success to correct place in check_feeds fixes #2 --- blogs/management/commands/check_feeds.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/blogs/management/commands/check_feeds.py b/blogs/management/commands/check_feeds.py index 6da1f62..e0c2426 100644 --- a/blogs/management/commands/check_feeds.py +++ b/blogs/management/commands/check_feeds.py @@ -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,10 +167,9 @@ class Command(BaseCommand): newish = instance.pubdate > cutoff if newish: instance.announce() - - blog.set_success( - updateddate=date_to_tz_aware(article.updated_parsed) - ) + blog.set_success( + updateddate=date_to_tz_aware(article.updated_parsed) + ) except Exception as e: blog.set_failing() From ea2b27c887acab1d1eee724bf3403a2ff2cd6d96 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 23 Mar 2024 16:23:41 +1100 Subject: [PATCH 2/2] fix contact form fixes #3 fixes #4 --- blogs/forms.py | 12 ++++++++++++ blogs/templates/contact.html | 14 ++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/blogs/forms.py b/blogs/forms.py index 3279350..3369745 100644 --- a/blogs/forms.py +++ b/blogs/forms.py @@ -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): diff --git a/blogs/templates/contact.html b/blogs/templates/contact.html index 5c972ec..b9233ea 100644 --- a/blogs/templates/contact.html +++ b/blogs/templates/contact.html @@ -10,16 +10,10 @@
- - {% if errors %} {{ form.from_email.errors }} {% endif %} - {{form.from_email}} - - {% if errors %} {{ form.subject.errors }} {% endif %} - {{form.subject}} - {% if errors %} {{ form.message.errors }} {% endif %} - - - + {{form}} +
+ +