From 403e282d888da9ad02a1a5e6da88c190d9f48994 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Sun, 28 Nov 2021 21:52:28 +0100
Subject: [PATCH 01/18] Add `aria-describedby` to field help/error messages
---
bookwyrm/forms.py | 43 +++++++++++++++++++
.../templates/preferences/delete_user.html | 4 +-
bookwyrm/templates/preferences/edit_user.html | 22 ++++++----
bookwyrm/templates/settings/site.html | 8 ++--
4 files changed, 62 insertions(+), 15 deletions(-)
diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py
index 847ca05c..aed5a794 100644
--- a/bookwyrm/forms.py
+++ b/bookwyrm/forms.py
@@ -9,6 +9,7 @@ from django.utils import timezone
from django.utils.translation import gettext_lazy as _
from bookwyrm import models
+from bookwyrm.models.fields import ClearableFileInputWithWarning
class CustomForm(ModelForm):
@@ -147,6 +148,23 @@ class EditUserForm(CustomForm):
"preferred_language",
]
help_texts = {f: None for f in fields}
+ widgets = {
+ "avatar": ClearableFileInputWithWarning(
+ attrs={'aria-describedby': "desc_avatar"}
+ ),
+ "name": forms.TextInput(
+ attrs={'aria-describedby': "desc_name"}
+ ),
+ "summary": forms.Textarea(
+ attrs={'aria-describedby': "desc_summary"}
+ ),
+ "email": forms.EmailInput(
+ attrs={'aria-describedby': "desc_email"}
+ ),
+ "discoverable": forms.CheckboxInput(
+ attrs={'aria-describedby': "desc_discoverable"}
+ ),
+ }
class LimitedEditUserForm(CustomForm):
@@ -160,6 +178,20 @@ class LimitedEditUserForm(CustomForm):
"discoverable",
]
help_texts = {f: None for f in fields}
+ widgets = {
+ "avatar": ClearableFileInputWithWarning(
+ attrs={'aria-describedby': "desc_avatar"}
+ ),
+ "name": forms.TextInput(
+ attrs={'aria-describedby': "desc_name"}
+ ),
+ "summary": forms.Textarea(
+ attrs={'aria-describedby': "desc_summary"}
+ ),
+ "discoverable": forms.CheckboxInput(
+ attrs={'aria-describedby': "desc_discoverable"}
+ ),
+ }
class DeleteUserForm(CustomForm):
@@ -288,6 +320,17 @@ class SiteForm(CustomForm):
class Meta:
model = models.SiteSettings
exclude = []
+ widgets = {
+ "instance_short_description": forms.TextInput(
+ attrs={'aria-describedby': "desc_instance_short_description"}
+ ),
+ "require_confirm_email": forms.CheckboxInput(
+ attrs={'aria-describedby': "desc_require_confirm_email"}
+ ),
+ "invite_request_text": forms.Textarea(
+ attrs={'aria-describedby': "desc_invite_request_text"}
+ ),
+ }
class AnnouncementForm(CustomForm):
diff --git a/bookwyrm/templates/preferences/delete_user.html b/bookwyrm/templates/preferences/delete_user.html
index 63bd2f86..a72cc97d 100644
--- a/bookwyrm/templates/preferences/delete_user.html
+++ b/bookwyrm/templates/preferences/delete_user.html
@@ -18,9 +18,9 @@
{% csrf_token %}
-
+
{% for error in form.password.errors %}
-
{{ error | escape }}
+
{{ error | escape }}
{% endfor %}
diff --git a/bookwyrm/templates/preferences/edit_user.html b/bookwyrm/templates/preferences/edit_user.html
index 72c49dbe..a3f8962c 100644
--- a/bookwyrm/templates/preferences/edit_user.html
+++ b/bookwyrm/templates/preferences/edit_user.html
@@ -34,7 +34,7 @@
{{ form.avatar }}
{% for error in form.avatar.errors %}
-
{{ error | escape }}
+
{{ error | escape }}
{% endfor %}
@@ -42,21 +42,21 @@
{{ form.name }}
{% for error in form.name.errors %}
- {{ error | escape }}
+ {{ error | escape }}
{% endfor %}
{{ form.summary }}
{% for error in form.summary.errors %}
-
{{ error | escape }}
+
{{ error | escape }}
{% endfor %}
{{ form.email }}
{% for error in form.email.errors %}
-
{{ error | escape }}
+
{{ error | escape }}
{% endfor %}
@@ -69,19 +69,23 @@
+
+
+
+
{% url 'directory' as path %}
-
+
{% blocktrans %}Your account will show up in the directory, and may be recommended to other BookWyrm users.{% endblocktrans %}
@@ -107,8 +111,8 @@
diff --git a/bookwyrm/templates/settings/site.html b/bookwyrm/templates/settings/site.html
index 94a4dd45..01b25036 100644
--- a/bookwyrm/templates/settings/site.html
+++ b/bookwyrm/templates/settings/site.html
@@ -33,8 +33,8 @@
{{ site_form.instance_description }}
-
-
{% trans "Used when the instance is previewed on joinbookwyrm.com. Does not support HTML or Markdown." %}
+
+
{% trans "Used when the instance is previewed on joinbookwyrm.com. Does not support HTML or Markdown." %}
{{ site_form.instance_short_description }}
@@ -114,7 +114,7 @@
{{ site_form.require_confirm_email }}
{% trans "Require users to confirm email address" %}
-
{% trans "(Recommended if registration is open)" %}
+
{% trans "(Recommended if registration is open)" %}
@@ -124,7 +124,7 @@
{{ site_form.invite_request_text }}
{% for error in site_form.invite_request_text.errors %}
-
{{ error|escape }}
+
{{ error|escape }}
{% endfor %}
From 85c688b1475bf79649f49619d8ab56a3200cd9b7 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Sun, 28 Nov 2021 22:01:49 +0100
Subject: [PATCH 02/18] Update forms.py
---
bookwyrm/forms.py | 34 ++++++++++++----------------------
1 file changed, 12 insertions(+), 22 deletions(-)
diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py
index aed5a794..ffbb237b 100644
--- a/bookwyrm/forms.py
+++ b/bookwyrm/forms.py
@@ -150,19 +150,13 @@ class EditUserForm(CustomForm):
help_texts = {f: None for f in fields}
widgets = {
"avatar": ClearableFileInputWithWarning(
- attrs={'aria-describedby': "desc_avatar"}
- ),
- "name": forms.TextInput(
- attrs={'aria-describedby': "desc_name"}
- ),
- "summary": forms.Textarea(
- attrs={'aria-describedby': "desc_summary"}
- ),
- "email": forms.EmailInput(
- attrs={'aria-describedby': "desc_email"}
+ attrs={"aria-describedby": "desc_avatar"}
),
+ "name": forms.TextInput(attrs={"aria-describedby": "desc_name"}),
+ "summary": forms.Textarea(attrs={"aria-describedby": "desc_summary"}),
+ "email": forms.EmailInput(attrs={"aria-describedby": "desc_email"}),
"discoverable": forms.CheckboxInput(
- attrs={'aria-describedby': "desc_discoverable"}
+ attrs={"aria-describedby": "desc_discoverable"}
),
}
@@ -180,16 +174,12 @@ class LimitedEditUserForm(CustomForm):
help_texts = {f: None for f in fields}
widgets = {
"avatar": ClearableFileInputWithWarning(
- attrs={'aria-describedby': "desc_avatar"}
- ),
- "name": forms.TextInput(
- attrs={'aria-describedby': "desc_name"}
- ),
- "summary": forms.Textarea(
- attrs={'aria-describedby': "desc_summary"}
+ attrs={"aria-describedby": "desc_avatar"}
),
+ "name": forms.TextInput(attrs={"aria-describedby": "desc_name"}),
+ "summary": forms.Textarea(attrs={"aria-describedby": "desc_summary"}),
"discoverable": forms.CheckboxInput(
- attrs={'aria-describedby': "desc_discoverable"}
+ attrs={"aria-describedby": "desc_discoverable"}
),
}
@@ -322,13 +312,13 @@ class SiteForm(CustomForm):
exclude = []
widgets = {
"instance_short_description": forms.TextInput(
- attrs={'aria-describedby': "desc_instance_short_description"}
+ attrs={"aria-describedby": "desc_instance_short_description"}
),
"require_confirm_email": forms.CheckboxInput(
- attrs={'aria-describedby': "desc_require_confirm_email"}
+ attrs={"aria-describedby": "desc_require_confirm_email"}
),
"invite_request_text": forms.Textarea(
- attrs={'aria-describedby': "desc_invite_request_text"}
+ attrs={"aria-describedby": "desc_invite_request_text"}
),
}
From dd0114c64468b84323aa7cc7526baee683ca07b5 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 22:33:03 +0100
Subject: [PATCH 03/18] Include errors display snippet
---
.../templates/preferences/delete_user.html | 5 ++---
bookwyrm/templates/preferences/edit_user.html | 20 ++++++++-----------
bookwyrm/templates/settings/site.html | 5 ++---
bookwyrm/templates/snippets/form_errors.html | 9 +++++++++
4 files changed, 21 insertions(+), 18 deletions(-)
create mode 100644 bookwyrm/templates/snippets/form_errors.html
diff --git a/bookwyrm/templates/preferences/delete_user.html b/bookwyrm/templates/preferences/delete_user.html
index a72cc97d..b009230c 100644
--- a/bookwyrm/templates/preferences/delete_user.html
+++ b/bookwyrm/templates/preferences/delete_user.html
@@ -19,9 +19,8 @@
- {% for error in form.password.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.password.errors id="desc_password" %}
diff --git a/bookwyrm/templates/preferences/edit_user.html b/bookwyrm/templates/preferences/edit_user.html
index a3f8962c..b18eb4e9 100644
--- a/bookwyrm/templates/preferences/edit_user.html
+++ b/bookwyrm/templates/preferences/edit_user.html
@@ -33,31 +33,27 @@
{% endif %}
{{ form.avatar }}
- {% for error in form.avatar.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.avatar.errors id="desc_avatar" %}
{{ form.name }}
- {% for error in form.name.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.name.errors id="desc_name" %}
{{ form.summary }}
- {% for error in form.summary.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.summary.errors id="desc_summary" %}
{{ form.email }}
- {% for error in form.email.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.email.errors id="desc_email" %}
diff --git a/bookwyrm/templates/settings/site.html b/bookwyrm/templates/settings/site.html
index 01b25036..3c05e147 100644
--- a/bookwyrm/templates/settings/site.html
+++ b/bookwyrm/templates/settings/site.html
@@ -123,9 +123,8 @@
{{ site_form.invite_request_text }}
- {% for error in site_form.invite_request_text.errors %}
-
{{ error|escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=site_form.invite_request_text.errors id="desc_invite_request_text" %}
diff --git a/bookwyrm/templates/snippets/form_errors.html b/bookwyrm/templates/snippets/form_errors.html
new file mode 100644
index 00000000..ecbf7ff8
--- /dev/null
+++ b/bookwyrm/templates/snippets/form_errors.html
@@ -0,0 +1,9 @@
+{% if errors_list %}
+
+ {% for error in errors_list %}
+
+ {{ error | escape }}
+
+ {% endfor %}
+
+{% endif %}
From 28f0882ba61dec1f41748d7e0ea9477ae1f71168 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 22:39:01 +0100
Subject: [PATCH 04/18] Handle Author form errors
---
bookwyrm/forms.py | 34 ++++++++++++++-
bookwyrm/templates/author/edit_author.html | 50 +++++++++-------------
2 files changed, 53 insertions(+), 31 deletions(-)
diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py
index ffbb237b..88820c8f 100644
--- a/bookwyrm/forms.py
+++ b/bookwyrm/forms.py
@@ -236,7 +236,39 @@ class AuthorForm(CustomForm):
"librarything_key",
"goodreads_key",
]
-
+ widgets = {
+ "name": forms.TextInput(
+ attrs={"aria-describedby": "desc_name"}
+ ),
+ "aliases": forms.TextInput(
+ attrs={"aria-describedby": "desc_aliases"}
+ ),
+ "bio": forms.Textarea(
+ attrs={"aria-describedby": "desc_bio"}
+ ),
+ "wikipedia_link": forms.TextInput(
+ attrs={"aria-describedby": "desc_wikipedia_link"}
+ ),
+ "born": forms.SelectDateWidget(
+ attrs={"aria-describedby": "desc_born"}
+ ),
+ "died": forms.SelectDateWidget(
+ attrs={"aria-describedby": "desc_died"}
+ ),
+ "oepnlibrary_key": forms.TextInput(
+ attrs={"aria-describedby": "desc_oepnlibrary_key"}
+ ),
+ "inventaire_id": forms.TextInput(
+ attrs={"aria-describedby": "desc_inventaire_id"}
+ ),
+ "librarything_key": forms.TextInput(
+ attrs={"aria-describedby": "desc_librarything_key"}
+ ),
+ "goodreads_key": forms.TextInput(
+ attrs={"aria-describedby": "desc_goodreads_key"}
+ ),
+ }
+
class ImportForm(forms.Form):
csv_file = forms.FileField()
diff --git a/bookwyrm/templates/author/edit_author.html b/bookwyrm/templates/author/edit_author.html
index 54d7f4f1..de1a7875 100644
--- a/bookwyrm/templates/author/edit_author.html
+++ b/bookwyrm/templates/author/edit_author.html
@@ -34,47 +34,41 @@
{{ form.name }}
- {% for error in form.name.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.name.errors id="desc_name" %}
{{ form.aliases }}
{% trans "Separate multiple values with commas." %}
- {% for error in form.aliases.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.aliases.errors id="desc_aliases" %}
{{ form.bio }}
- {% for error in form.bio.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.bio.errors id="desc_bio" %}
{{ form.wikipedia_link }}
- {% for error in form.wikipedia_link.errors %}
- {{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.wikipedia_link.errors id="desc_wikipedia_link" %}
- {% for error in form.born.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.born.errors id="desc_born" %}
- {% for error in form.died.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.died.errors id="desc_died" %}
@@ -82,33 +76,29 @@
{{ form.openlibrary_key }}
- {% for error in form.openlibrary_key.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.oepnlibrary_key.errors id="desc_oepnlibrary_key" %}
{{ form.inventaire_id }}
- {% for error in form.inventaire_id.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.inventaire_id.errors id="desc_inventaire_id" %}
{{ form.librarything_key }}
- {% for error in form.librarything_key.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.librarything_key.errors id="desc_librarything_key" %}
{{ form.goodreads_key }}
- {% for error in form.goodreads_key.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.goodreads_key.errors id="desc_goodreads_key" %}
From adb0d356a8d81ed63c64e74befa9a4ac9dcfea76 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 22:39:44 +0100
Subject: [PATCH 05/18] Update site.html
---
bookwyrm/templates/settings/site.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/bookwyrm/templates/settings/site.html b/bookwyrm/templates/settings/site.html
index 3c05e147..8efad308 100644
--- a/bookwyrm/templates/settings/site.html
+++ b/bookwyrm/templates/settings/site.html
@@ -124,7 +124,7 @@
{{ site_form.invite_request_text }}
- {% include 'snippets/form_errors.html' with errors_list=site_form.invite_request_text.errors id="desc_invite_request_text" %}
+ {% include 'snippets/form_errors.html' with errors_list=site_form.invite_request_text.errors id="desc_invite_request_text" %}
From c2873c601f4deb2efa05af166fe49c9a373479af Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:26:25 +0100
Subject: [PATCH 06/18] Register form
---
.../templates/snippets/register_form.html | 25 +++++++++----------
1 file changed, 12 insertions(+), 13 deletions(-)
diff --git a/bookwyrm/templates/snippets/register_form.html b/bookwyrm/templates/snippets/register_form.html
index 9e610bd1..a1af78ef 100644
--- a/bookwyrm/templates/snippets/register_form.html
+++ b/bookwyrm/templates/snippets/register_form.html
@@ -3,32 +3,31 @@
-
+
From 08b4c538e621f0ba979f94aeefa89064a304d5e7 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:26:43 +0100
Subject: [PATCH 07/18] User moderation actions
---
.../users/user_moderation_actions.html | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/bookwyrm/templates/settings/users/user_moderation_actions.html b/bookwyrm/templates/settings/users/user_moderation_actions.html
index a976359f..b5f69529 100644
--- a/bookwyrm/templates/settings/users/user_moderation_actions.html
+++ b/bookwyrm/templates/settings/users/user_moderation_actions.html
@@ -50,18 +50,23 @@
{% endif %}
{% with group=user.groups.first %}
-
- {% for error in group_form.groups.errors %}
- {{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=group_form.groups.errors id="desc_user_group" %}
{% endwith %}
-
+
{% endif %}
From a154597de179d76f491499a06c72db430db198f1 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:26:53 +0100
Subject: [PATCH 08/18] Delete user form
---
bookwyrm/templates/settings/users/delete_user_form.html | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/bookwyrm/templates/settings/users/delete_user_form.html b/bookwyrm/templates/settings/users/delete_user_form.html
index 158745d0..1ea63269 100644
--- a/bookwyrm/templates/settings/users/delete_user_form.html
+++ b/bookwyrm/templates/settings/users/delete_user_form.html
@@ -15,10 +15,9 @@
From 0a621550b8863d7dda304864f09a12b4e0248baf Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:27:04 +0100
Subject: [PATCH 09/18] IP address form
---
.../settings/ip_blocklist/ip_address_form.html | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/bookwyrm/templates/settings/ip_blocklist/ip_address_form.html b/bookwyrm/templates/settings/ip_blocklist/ip_address_form.html
index c8a4c3e7..4a776987 100644
--- a/bookwyrm/templates/settings/ip_blocklist/ip_address_form.html
+++ b/bookwyrm/templates/settings/ip_blocklist/ip_address_form.html
@@ -20,16 +20,16 @@
-
+
- {% for error in form.address.errors %}
- {{ error | escape }}
- {% endfor %}
+ {% include 'snippets/form_errors.html' with errors_list=form.address.errors id="desc_address" %}
-
+
From 5d0c6bdde24d9964848826bdf12f5683145655d6 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:27:25 +0100
Subject: [PATCH 10/18] Edit instance form
---
.../settings/federation/edit_instance.html | 45 +++++++++++--------
1 file changed, 27 insertions(+), 18 deletions(-)
diff --git a/bookwyrm/templates/settings/federation/edit_instance.html b/bookwyrm/templates/settings/federation/edit_instance.html
index 7c2e6be6..0a67895c 100644
--- a/bookwyrm/templates/settings/federation/edit_instance.html
+++ b/bookwyrm/templates/settings/federation/edit_instance.html
@@ -27,11 +27,12 @@
-
-
- {% for error in form.server_name.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.server_name.errors id="desc_server_name" %}
@@ -49,29 +50,37 @@
-
-
- {% for error in form.application_type.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.application_type.errors id="desc_application_type" %}
-
-
- {% for error in form.application_version.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.application_version.errors id="desc_application_version" %}
-
-
+
+
-
+
{% endblock %}
From a6760cabc86d99b23bda32e36464a4a913aa7c3c Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:28:29 +0100
Subject: [PATCH 11/18] Email domain form
---
bookwyrm/forms.py | 5 +++++
bookwyrm/templates/settings/email_blocklist/domain_form.html | 4 +---
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py
index 88820c8f..ddb02d93 100644
--- a/bookwyrm/forms.py
+++ b/bookwyrm/forms.py
@@ -383,6 +383,11 @@ class EmailBlocklistForm(CustomForm):
class Meta:
model = models.EmailBlocklist
fields = ["domain"]
+ widgets = {
+ "avatar": forms.TextInput(
+ attrs={'aria-describedby': "desc_domain"}
+ ),
+ }
class IPBlocklistForm(CustomForm):
diff --git a/bookwyrm/templates/settings/email_blocklist/domain_form.html b/bookwyrm/templates/settings/email_blocklist/domain_form.html
index e9333749..cebc97c8 100644
--- a/bookwyrm/templates/settings/email_blocklist/domain_form.html
+++ b/bookwyrm/templates/settings/email_blocklist/domain_form.html
@@ -17,10 +17,8 @@
{{ form.domain }}
- {% for error in form.domain.errors %}
- {{ error | escape }}
- {% endfor %}
+ {% include 'snippets/form_errors.html' with errors_list=form.domain.errors id="desc_domain" %}
From 659d13d0a60e80ac17e28ba2c41a295fb2b73422 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:28:51 +0100
Subject: [PATCH 12/18] Announcement form
---
bookwyrm/forms.py | 20 +++++++
.../announcements/announcement_form.html | 58 +++++++++++--------
2 files changed, 53 insertions(+), 25 deletions(-)
diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py
index ddb02d93..e8136a54 100644
--- a/bookwyrm/forms.py
+++ b/bookwyrm/forms.py
@@ -359,6 +359,26 @@ class AnnouncementForm(CustomForm):
class Meta:
model = models.Announcement
exclude = ["remote_id"]
+ widgets = {
+ "preview": forms.TextInput(
+ attrs={"aria-describedby": "desc_preview"}
+ ),
+ "content": forms.Textarea(
+ attrs={"aria-describedby": "desc_content"}
+ ),
+ "event_date": forms.SelectDateWidget(
+ attrs={"aria-describedby": "desc_event_date"}
+ ),
+ "start_date": forms.SelectDateWidget(
+ attrs={"aria-describedby": "desc_start_date"}
+ ),
+ "end_date": forms.SelectDateWidget(
+ attrs={"aria-describedby": "desc_end_date"}
+ ),
+ "active": forms.CheckboxInput(
+ attrs={"aria-describedby": "desc_active"}
+ ),
+ }
class ListForm(CustomForm):
diff --git a/bookwyrm/templates/settings/announcements/announcement_form.html b/bookwyrm/templates/settings/announcements/announcement_form.html
index ffdbfc2f..8f68e255 100644
--- a/bookwyrm/templates/settings/announcements/announcement_form.html
+++ b/bookwyrm/templates/settings/announcements/announcement_form.html
@@ -13,60 +13,68 @@
{% csrf_token %}
-
+
{{ form.preview }}
- {% for error in form.preview.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.preview.errors id="desc_preview" %}
-
+
{{ form.content }}
- {% for error in form.content.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.content.errors id="desc_content" %}
-
+
- {% for error in form.event_date.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.event_date.errors id="desc_event_date" %}
-
+
- {% for error in form.start_date.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.start_date.errors id="desc_start_date" %}
-
+
- {% for error in form.end_date.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.end_date.errors id="desc_end_date" %}
-
+
{{ form.active }}
- {% for error in form.active.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.active.errors id="desc_active" %}
-
+
{% endblock %}
From 63d31b8623d5eb084b049b5acbf8ae0a91da8408 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:29:22 +0100
Subject: [PATCH 13/18] Edit book form
---
bookwyrm/forms.py | 61 ++++-
.../templates/book/edit/edit_book_form.html | 229 ++++++++++--------
2 files changed, 194 insertions(+), 96 deletions(-)
diff --git a/bookwyrm/forms.py b/bookwyrm/forms.py
index e8136a54..3f46be34 100644
--- a/bookwyrm/forms.py
+++ b/bookwyrm/forms.py
@@ -218,6 +218,65 @@ class EditionForm(CustomForm):
"connector",
"search_vector",
]
+ widgets = {
+ "title": forms.TextInput(
+ attrs={"aria-describedby": "desc_title"}
+ ),
+ "subtitle": forms.TextInput(
+ attrs={"aria-describedby": "desc_subtitle"}
+ ),
+ "description": forms.Textarea(
+ attrs={"aria-describedby": "desc_description"}
+ ),
+ "series": forms.TextInput(
+ attrs={"aria-describedby": "desc_series"}
+ ),
+ "series_number": forms.TextInput(
+ attrs={"aria-describedby": "desc_series_number"}
+ ),
+ "languages": forms.TextInput(
+ attrs={"aria-describedby": "desc_languages_help desc_languages"}
+ ),
+ "publishers": forms.TextInput(
+ attrs={"aria-describedby": "desc_publishers_help desc_publishers"}
+ ),
+ "first_published_date": forms.SelectDateWidget(
+ attrs={"aria-describedby": "desc_first_published_date"}
+ ),
+ "published_date": forms.SelectDateWidget(
+ attrs={"aria-describedby": "desc_published_date"}
+ ),
+ "cover": ClearableFileInputWithWarning(
+ attrs={"aria-describedby": "desc_cover"}
+ ),
+ "physical_format": forms.Select(
+ attrs={"aria-describedby": "desc_physical_format"}
+ ),
+ "physical_format_detail": forms.TextInput(
+ attrs={"aria-describedby": "desc_physical_format_detail"}
+ ),
+ "pages": forms.NumberInput(
+ attrs={"aria-describedby": "desc_pages"}
+ ),
+ "isbn_13": forms.TextInput(
+ attrs={"aria-describedby": "desc_isbn_13"}
+ ),
+ "isbn_10": forms.TextInput(
+ attrs={"aria-describedby": "desc_isbn_10"}
+ ),
+ "openlibrary_key": forms.TextInput(
+ attrs={"aria-describedby": "desc_openlibrary_key"}
+ ),
+ "inventaire_id": forms.TextInput(
+ attrs={"aria-describedby": "desc_inventaire_id"}
+ ),
+ "oclc_number": forms.TextInput(
+ attrs={"aria-describedby": "desc_oclc_number"}
+ ),
+ "ASIN": forms.TextInput(
+ attrs={"aria-describedby": "desc_ASIN"}
+ ),
+ }
class AuthorForm(CustomForm):
@@ -268,7 +327,7 @@ class AuthorForm(CustomForm):
attrs={"aria-describedby": "desc_goodreads_key"}
),
}
-
+
class ImportForm(forms.Form):
csv_file = forms.FileField()
diff --git a/bookwyrm/templates/book/edit/edit_book_form.html b/bookwyrm/templates/book/edit/edit_book_form.html
index 982bb56d..feebb803 100644
--- a/bookwyrm/templates/book/edit/edit_book_form.html
+++ b/bookwyrm/templates/book/edit/edit_book_form.html
@@ -12,106 +12,125 @@
- {% trans "Metadata" %}
+
+ {% trans "Metadata" %}
+
-
-
- {% for error in form.title.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.title.errors id="desc_title" %}
-
-
- {% for error in form.subtitle.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.subtitle.errors id="desc_subtitle" %}
-
+
{{ form.description }}
- {% for error in form.description.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.description.errors id="desc_description" %}
-
-
- {% for error in form.series.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.series.errors id="desc_series" %}
-
+
{{ form.series_number }}
- {% for error in form.series_number.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.series_number.errors id="desc_series_number" %}
-
+
{{ form.languages }}
-
{% trans "Separate multiple values with commas." %}
- {% for error in form.languages.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% trans "Separate multiple values with commas." %}
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.languages.errors id="desc_languages" %}
- {% trans "Publication" %}
+
+ {% trans "Publication" %}
+
-
+
{{ form.publishers }}
-
{% trans "Separate multiple values with commas." %}
- {% for error in form.publishers.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% trans "Separate multiple values with commas." %}
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.publishers.errors id="desc_publishers" %}
-
-
- {% for error in form.first_published_date.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.first_published_date.errors id="desc_first_published_date" %}
-
-
- {% for error in form.published_date.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+
+
+ {% include 'snippets/form_errors.html' with errors_list=form.published_date.errors id="desc_published_date" %}
- {% trans "Authors" %}
+
+ {% trans "Authors" %}
+
@@ -129,7 +152,9 @@
- {% trans "Cover" %}
+
+ {% trans "Cover" %}
+
{% if book.cover %}
@@ -140,108 +165,122 @@
- {% trans "Physical Properties" %}
+
+ {% trans "Physical Properties" %}
+
-
+
{{ form.physical_format }}
- {% for error in form.physical_format.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.physical_format.errors id="desc_physical_format" %}
-
+
{{ form.physical_format_detail }}
- {% for error in form.physical_format_detail.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.physical_format_detail.errors id="desc_physical_format_detail" %}
-
+
{{ form.pages }}
- {% for error in form.pages.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.pages.errors id="desc_pages" %}
- {% trans "Book Identifiers" %}
+
+ {% trans "Book Identifiers" %}
+
-
+
{{ form.isbn_13 }}
- {% for error in form.isbn_13.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.isbn_13.errors id="desc_isbn_13" %}
-
+
{{ form.isbn_10 }}
- {% for error in form.isbn_10.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.isbn_10.errors id="desc_isbn_10" %}
-
+
{{ form.openlibrary_key }}
- {% for error in form.openlibrary_key.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.openlibrary_key.errors id="desc_openlibrary_key" %}
-
+
{{ form.inventaire_id }}
- {% for error in form.inventaire_id.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.inventaire_id.errors id="desc_inventaire_id" %}
-
+
{{ form.oclc_number }}
- {% for error in form.oclc_number.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.oclc_number.errors id="desc_oclc_number" %}
-
+
{{ form.asin }}
- {% for error in form.ASIN.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.ASIN.errors id="desc_ASIN" %}
From 3eb4dfdc9be1cb4bc8b7e7ce718a030fa9ce4985 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:29:36 +0100
Subject: [PATCH 14/18] Get started user form
---
bookwyrm/templates/get_started/profile.html | 15 ++++++---------
1 file changed, 6 insertions(+), 9 deletions(-)
diff --git a/bookwyrm/templates/get_started/profile.html b/bookwyrm/templates/get_started/profile.html
index 90cdb410..ef33afac 100644
--- a/bookwyrm/templates/get_started/profile.html
+++ b/bookwyrm/templates/get_started/profile.html
@@ -14,16 +14,14 @@
- {% for error in form.name.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.name.errors id="desc_name" %}
- {% for error in form.summary.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.summary.errors id="desc_summary" %}
@@ -31,9 +29,8 @@
{{ form.avatar }}
- {% for error in form.avatar.errors %}
-
{{ error | escape }}
- {% endfor %}
+
+ {% include 'snippets/form_errors.html' with errors_list=form.avatar.errors id="desc_avatar" %}
From 3cf9660df30f4eec6f4779029ce33cbf3752bf0f Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:29:56 +0100
Subject: [PATCH 15/18] Login form
---
bookwyrm/templates/landing/layout.html | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/bookwyrm/templates/landing/layout.html b/bookwyrm/templates/landing/layout.html
index 0d6f231c..56985768 100644
--- a/bookwyrm/templates/landing/layout.html
+++ b/bookwyrm/templates/landing/layout.html
@@ -65,10 +65,9 @@
{% csrf_token %}
From 80535a3b0caee396b82ca39207a4d03e251c9174 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:30:14 +0100
Subject: [PATCH 16/18] Login form
---
bookwyrm/templates/landing/login.html | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/bookwyrm/templates/landing/login.html b/bookwyrm/templates/landing/login.html
index 95baa06d..c9ac2526 100644
--- a/bookwyrm/templates/landing/login.html
+++ b/bookwyrm/templates/landing/login.html
@@ -26,11 +26,10 @@
From 43072a357f2f100907dafc608f9319444dc16f48 Mon Sep 17 00:00:00 2001
From: Joachim
Date: Mon, 29 Nov 2021 23:30:23 +0100
Subject: [PATCH 17/18] Password reset form
---
.../templates/landing/password_reset.html | 26 ++++++++++++++-----
1 file changed, 19 insertions(+), 7 deletions(-)
diff --git a/bookwyrm/templates/landing/password_reset.html b/bookwyrm/templates/landing/password_reset.html
index be1dccf8..8348efd4 100644
--- a/bookwyrm/templates/landing/password_reset.html
+++ b/bookwyrm/templates/landing/password_reset.html
@@ -8,21 +8,33 @@
{% trans "Reset Password" %}
- {% for error in errors %}
-
{{ error }}
- {% endfor %}
+
+ {% if errors %}
+
+
+ {% endif %}