Merge pull request #7 from hughrun/fixes

Various fixes
This commit is contained in:
Hugh Rundle 2024-03-23 16:26:43 +11:00 committed by GitHub
commit 57082c92c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 21 additions and 14 deletions

View file

@ -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):

View file

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

View file

@ -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>