commit
57082c92c9
|
@ -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):
|
||||||
|
|
|
@ -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,10 +167,9 @@ 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)
|
)
|
||||||
)
|
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
blog.set_failing()
|
blog.set_failing()
|
||||||
|
|
|
@ -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