Merge pull request #1638 from joachimesque/font-end-accessibility-improvements

Add `aria-describedby` to field help/error messages
This commit is contained in:
Mouse Reeve 2021-12-04 08:23:09 -08:00 committed by GitHub
commit 41fbfb627e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 425 additions and 249 deletions

View file

@ -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
from bookwyrm.models.user import FeedFilterChoices
@ -148,6 +149,17 @@ 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):
@ -161,6 +173,16 @@ 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):
@ -209,6 +231,51 @@ 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):
@ -227,6 +294,28 @@ 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):
@ -301,12 +390,37 @@ 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):
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):
@ -331,6 +445,9 @@ class EmailBlocklistForm(CustomForm):
class Meta:
model = models.EmailBlocklist
fields = ["domain"]
widgets = {
"avatar": forms.TextInput(attrs={"aria-describedby": "desc_domain"}),
}
class IPBlocklistForm(CustomForm):

View file

@ -34,47 +34,41 @@
<div class="field">
<label class="label" for="id_name">{% trans "Name:" %}</label>
{{ form.name }}
{% for error in form.name.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.name.errors id="desc_name" %}
</div>
<div class="field">
<label class="label" for="id_aliases">{% trans "Aliases:" %}</label>
{{ form.aliases }}
<span class="help">{% trans "Separate multiple values with commas." %}</span>
{% for error in form.aliases.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.aliases.errors id="desc_aliases" %}
</div>
<div class="field">
<label class="label" for="id_bio">{% trans "Bio:" %}</label>
{{ form.bio }}
{% for error in form.bio.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.bio.errors id="desc_bio" %}
</div>
<p class="field"><label class="label" for="id_wikipedia_link">{% trans "Wikipedia link:" %}</label> {{ form.wikipedia_link }}</p>
{% for error in form.wikipedia_link.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.wikipedia_link.errors id="desc_wikipedia_link" %}
<div class="field">
<label class="label" for="id_born">{% trans "Birth date:" %}</label>
<input type="date" name="born" value="{{ form.born.value|date:'Y-m-d' }}" class="input" id="id_born">
{% for error in form.born.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.born.errors id="desc_born" %}
</div>
<div class="field">
<label class="label" for="id_died">{% trans "Death date:" %}</label>
<input type="date" name="died" value="{{ form.died.value|date:'Y-m-d' }}" class="input" id="id_died">
{% for error in form.died.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.died.errors id="desc_died" %}
</div>
</div>
<div class="column">
@ -82,33 +76,29 @@
<div class="field">
<label class="label" for="id_openlibrary_key">{% trans "Openlibrary key:" %}</label>
{{ form.openlibrary_key }}
{% for error in form.openlibrary_key.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.oepnlibrary_key.errors id="desc_oepnlibrary_key" %}
</div>
<div class="field">
<label class="label" for="id_inventaire_id">{% trans "Inventaire ID:" %}</label>
{{ form.inventaire_id }}
{% for error in form.inventaire_id.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.inventaire_id.errors id="desc_inventaire_id" %}
</div>
<div class="field">
<label class="label" for="id_librarything_key">{% trans "Librarything key:" %}</label>
{{ form.librarything_key }}
{% for error in form.librarything_key.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.librarything_key.errors id="desc_librarything_key" %}
</div>
<div class="field">
<label class="label" for="id_goodreads_key">{% trans "Goodreads key:" %}</label>
{{ form.goodreads_key }}
{% for error in form.goodreads_key.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.goodreads_key.errors id="desc_goodreads_key" %}
</div>
</div>

View file

@ -12,106 +12,125 @@
<div class="columns">
<div class="column is-half">
<section class="block">
<h2 class="title is-4">{% trans "Metadata" %}</h2>
<h2 class="title is-4">
{% trans "Metadata" %}
</h2>
<div class="box">
<div class="field">
<label class="label" for="id_title">{% trans "Title:" %}</label>
<input type="text" name="title" value="{{ form.title.value|default:'' }}" maxlength="255" class="input" required="" id="id_title">
{% for error in form.title.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<label class="label" for="id_title">
{% trans "Title:" %}
</label>
<input type="text" name="title" value="{{ form.title.value|default:'' }}" maxlength="255" class="input" required="" id="id_title" aria-describedby="desc_title">
{% include 'snippets/form_errors.html' with errors_list=form.title.errors id="desc_title" %}
</div>
<div class="field">
<label class="label" for="id_subtitle">{% trans "Subtitle:" %}</label>
<input type="text" name="subtitle" value="{{ form.subtitle.value|default:'' }}" maxlength="255" class="input" id="id_subtitle">
{% for error in form.subtitle.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<label class="label" for="id_subtitle">
{% trans "Subtitle:" %}
</label>
<input type="text" name="subtitle" value="{{ form.subtitle.value|default:'' }}" maxlength="255" class="input" id="id_subtitle" aria-describedby="desc_subtitle">
{% include 'snippets/form_errors.html' with errors_list=form.subtitle.errors id="desc_subtitle" %}
</div>
<div class="field">
<label class="label" for="id_description">{% trans "Description:" %}</label>
<label class="label" for="id_description">
{% trans "Description:" %}
</label>
{{ form.description }}
{% for error in form.description.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.description.errors id="desc_description" %}
</div>
<div class="columns">
<div class="column is-two-thirds">
<div class="field">
<label class="label" for="id_series">{% trans "Series:" %}</label>
<input type="text" class="input" name="series" id="id_series" value="{{ form.series.value|default:'' }}">
{% for error in form.series.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<label class="label" for="id_series">
{% trans "Series:" %}
</label>
<input type="text" class="input" name="series" id="id_series" value="{{ form.series.value|default:'' }}" aria-describedby="desc_series">
{% include 'snippets/form_errors.html' with errors_list=form.series.errors id="desc_series" %}
</div>
</div>
<div class="column is-one-third">
<div class="field">
<label class="label" for="id_series_number">{% trans "Series number:" %}</label>
<label class="label" for="id_series_number">
{% trans "Series number:" %}
</label>
{{ form.series_number }}
{% for error in form.series_number.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.series_number.errors id="desc_series_number" %}
</div>
</div>
</div>
<div class="field">
<label class="label" for="id_languages">{% trans "Languages:" %}</label>
<label class="label" for="id_languages">
{% trans "Languages:" %}
</label>
{{ form.languages }}
<span class="help">{% trans "Separate multiple values with commas." %}</span>
{% for error in form.languages.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<span class="help" id="desc_languages_help">
{% trans "Separate multiple values with commas." %}
</span>
{% include 'snippets/form_errors.html' with errors_list=form.languages.errors id="desc_languages" %}
</div>
</div>
</section>
<section class="block">
<h2 class="title is-4">{% trans "Publication" %}</h2>
<h2 class="title is-4">
{% trans "Publication" %}
</h2>
<div class="box">
<div class="field">
<label class="label" for="id_publishers">{% trans "Publisher:" %}</label>
<label class="label" for="id_publishers">
{% trans "Publisher:" %}
</label>
{{ form.publishers }}
<span class="help">{% trans "Separate multiple values with commas." %}</span>
{% for error in form.publishers.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<span class="help" id="desc_publishers_help">
{% trans "Separate multiple values with commas." %}
</span>
{% include 'snippets/form_errors.html' with errors_list=form.publishers.errors id="desc_publishers" %}
</div>
<div class="field">
<label class="label" for="id_first_published_date">{% trans "First published date:" %}</label>
<input type="date" name="first_published_date" class="input" id="id_first_published_date"{% if form.first_published_date.value %} value="{{ form.first_published_date.value|date:'Y-m-d' }}"{% endif %}>
{% for error in form.first_published_date.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<label class="label" for="id_first_published_date">
{% trans "First published date:" %}
</label>
<input type="date" name="first_published_date" class="input" id="id_first_published_date"{% if form.first_published_date.value %} value="{{ form.first_published_date.value|date:'Y-m-d' }}"{% endif %} aria-describedby="desc_first_published_date">
{% include 'snippets/form_errors.html' with errors_list=form.first_published_date.errors id="desc_first_published_date" %}
</div>
<div class="field">
<label class="label" for="id_published_date">{% trans "Published date:" %}</label>
<input type="date" name="published_date" class="input" id="id_published_date"{% if form.published_date.value %} value="{{ form.published_date.value|date:'Y-m-d'}}"{% endif %}>
{% for error in form.published_date.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<label class="label" for="id_published_date">
{% trans "Published date:" %}
</label>
<input type="date" name="published_date" class="input" id="id_published_date"{% if form.published_date.value %} value="{{ form.published_date.value|date:'Y-m-d'}}"{% endif %} aria-describedby="desc_published_date">
{% include 'snippets/form_errors.html' with errors_list=form.published_date.errors id="desc_published_date" %}
</div>
</div>
</section>
<section class="block">
<h2 class="title is-4">{% trans "Authors" %}</h2>
<h2 class="title is-4">
{% trans "Authors" %}
</h2>
<div class="box">
{% if book.authors.exists %}
<fieldset>
{% for author in book.authors.all %}
<div class="is-flex is-justify-content-space-between">
<label class="label mb-2">
<input type="checkbox" name="remove_authors" value="{{ author.id }}" {% if author.id|stringformat:"i" in remove_authors %}checked{% endif %}>
<input type="checkbox" name="remove_authors" value="{{ author.id }}" {% if author.id|stringformat:"i" in remove_authors %}checked{% endif %} aria-describedby="desc_remove_author_{{author.id}}">
{% blocktrans with name=author.name %}Remove {{ name }}{% endblocktrans %}
</label>
<p class="help">
<p class="help" id="desc_remove_author_{{author.id}}">
<a href="{{ author.local_path }}">{% blocktrans with name=author.name %}Author page for {{ name }}{% endblocktrans %}</a>
</p>
</div>
@ -119,7 +138,9 @@
</fieldset>
{% endif %}
<div class="field">
<label class="label">{% trans "Add Authors:" %}</label>
<label class="label" for="id_add_author">
{% trans "Add Authors:" %}
</label>
{% for author in add_author %}
<label class="label is-sr-only" for="id_add_author{% if not forloop.first %}-{{forloop.counter}}{% endif %}">{% trans "Add Author" %}</label>
<input class="input" type="text" name="add_author" id="id_add_author{% if not forloop.first %}-{{forloop.counter}}{% endif %}" placeholder="{% trans 'Jane Doe' %}" value="{{ author }}" {% if confirm_mode %}readonly{% endif %}>
@ -135,7 +156,9 @@
<div class="column is-half">
<section class="block">
<h2 class="title is-4">{% trans "Cover" %}</h2>
<h2 class="title is-4">
{% trans "Cover" %}
</h2>
<div class="box">
<div class="columns">
{% if book.cover %}
@ -146,108 +169,122 @@
<div class="column">
<div class="field">
<label class="label" for="id_cover">{% trans "Upload cover:" %}</label>
<label class="label" for="id_cover">
{% trans "Upload cover:" %}
</label>
{{ form.cover }}
</div>
<div class="field">
<label class="label" for="id_cover_url">
{% trans "Load cover from url:" %}
</label>
<input class="input" name="cover-url" id="id_cover_url" type="url" value="{{ cover_url|default:'' }}">
<input class="input" name="cover-url" id="id_cover_url" type="url" value="{{ cover_url|default:'' }}" aria-describedby="desc_cover">
</div>
{% for error in form.cover.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.cover.errors id="desc_cover" %}
</div>
</div>
</div>
</section>
<section class="block">
<h2 class="title is-4">{% trans "Physical Properties" %}</h2>
<h2 class="title is-4">
{% trans "Physical Properties" %}
</h2>
<div class="box">
<div class="columns">
<div class="column is-one-third">
<div class="field">
<label class="label" for="id_physical_format">{% trans "Format:" %}</label>
<label class="label" for="id_physical_format">
{% trans "Format:" %}
</label>
<div class="select">
{{ form.physical_format }}
</div>
{% for error in form.physical_format.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.physical_format.errors id="desc_physical_format" %}
</div>
</div>
<div class="column">
<div class="field">
<label class="label" for="id_physical_format_detail">{% trans "Format details:" %}</label>
<label class="label" for="id_physical_format_detail">
{% trans "Format details:" %}
</label>
{{ form.physical_format_detail }}
{% for error in form.physical_format_detail.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.physical_format_detail.errors id="desc_physical_format_detail" %}
</div>
</div>
</div>
<div class="field">
<label class="label" for="id_pages">{% trans "Pages:" %}</label>
<label class="label" for="id_pages">
{% trans "Pages:" %}
</label>
{{ form.pages }}
{% for error in form.pages.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.pages.errors id="desc_pages" %}
</div>
</div>
</section>
<section class="block">
<h2 class="title is-4">{% trans "Book Identifiers" %}</h2>
<h2 class="title is-4">
{% trans "Book Identifiers" %}
</h2>
<div class="box">
<div class="field">
<label class="label" for="id_isbn_13">{% trans "ISBN 13:" %}</label>
<label class="label" for="id_isbn_13">
{% trans "ISBN 13:" %}
</label>
{{ form.isbn_13 }}
{% for error in form.isbn_13.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.isbn_13.errors id="desc_isbn_13" %}
</div>
<div class="field">
<label class="label" for="id_isbn_10">{% trans "ISBN 10:" %}</label>
<label class="label" for="id_isbn_10">
{% trans "ISBN 10:" %}
</label>
{{ form.isbn_10 }}
{% for error in form.isbn_10.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.isbn_10.errors id="desc_isbn_10" %}
</div>
<div class="field">
<label class="label" for="id_openlibrary_key">{% trans "Openlibrary ID:" %}</label>
<label class="label" for="id_openlibrary_key">
{% trans "Openlibrary ID:" %}
</label>
{{ form.openlibrary_key }}
{% for error in form.openlibrary_key.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.openlibrary_key.errors id="desc_openlibrary_key" %}
</div>
<div class="field">
<label class="label" for="id_inventaire_id">{% trans "Inventaire ID:" %}</label>
<label class="label" for="id_inventaire_id">
{% trans "Inventaire ID:" %}
</label>
{{ form.inventaire_id }}
{% for error in form.inventaire_id.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.inventaire_id.errors id="desc_inventaire_id" %}
</div>
<div class="field">
<label class="label" for="id_oclc_number">{% trans "OCLC Number:" %}</label>
<label class="label" for="id_oclc_number">
{% trans "OCLC Number:" %}
</label>
{{ form.oclc_number }}
{% for error in form.oclc_number.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.oclc_number.errors id="desc_oclc_number" %}
</div>
<div class="field">
<label class="label" for="id_asin">{% trans "ASIN:" %}</label>
<label class="label" for="id_asin">
{% trans "ASIN:" %}
</label>
{{ form.asin }}
{% for error in form.ASIN.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.ASIN.errors id="desc_ASIN" %}
</div>
</div>
</section>

View file

@ -14,16 +14,14 @@
<div class="block">
<label class="label" for="id_name">{% trans "Display name:" %}</label>
<input type="text" name="name" maxlength="100" class="input" id="id_name" placeholder="{{ user.localname }}" value="{% if request.user.name %}{{ request.user.name }}{% endif %}">
{% for error in form.name.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.name.errors id="desc_name" %}
</div>
<div class="block">
<label class="label" for="id_summary">{% trans "Summary:" %}</label>
<textarea name="summary" cols="None" rows="None" class="textarea" id="id_summary" placeholder="{% trans 'A little bit about you' %}">{% if request.user.summary %}{{ request.user.summary }}{% endif %}</textarea>
{% for error in form.summary.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.summary.errors id="desc_summary" %}
</div>
</div>
@ -31,9 +29,8 @@
<div class="block">
<label class="label" for="id_avatar">{% trans "Avatar:" %}</label>
{{ form.avatar }}
{% for error in form.avatar.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.avatar.errors id="desc_avatar" %}
</div>
</div>
</div>

View file

@ -65,10 +65,9 @@
{% csrf_token %}
<div class="block">
<label for="id_request_email" class="label">{% trans "Email address:" %}</label>
<input type="email" name="email" maxlength="255" class="input" required="" id="id_request_email">
{% for error in request_form.email.errors %}
<p class="help is-danger">{{ error|escape }}</p>
{% endfor %}
<input type="email" name="email" maxlength="255" class="input" required="" id="id_request_email" aria-describedby="desc_request_email">
{% include 'snippets/form_errors.html' with errors_list=request_form.email.errors id="desc_request_email" %}
</div>
<button type="submit" class="button is-link">{% trans "Submit" %}</button>
</form>

View file

@ -26,11 +26,10 @@
<div class="field">
<label class="label" for="id_password_confirm">{% trans "Password:" %}</label>
<div class="control">
<input type="password" name="password" maxlength="128" class="input" required="" id="id_password_confirm">
<input type="password" name="password" maxlength="128" class="input" required="" id="id_password_confirm" aria-describedby="desc_password">
</div>
{% for error in login_form.password.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=login_form.password.errors id="desc_password" %}
</div>
<div class="field is-grouped">
<div class="control">

View file

@ -8,21 +8,33 @@
<div class="column">
<div class="block">
<h1 class="title">{% trans "Reset Password" %}</h1>
{% for error in errors %}
<p class="is-danger">{{ error }}</p>
{% endfor %}
{% if errors %}
<div id="form_errors">
{% for error in errors %}
<p class="is-danger">
{{ error }}
</p>
{% endfor %}
</div>
{% endif %}
<form name="password-reset" method="post" action="/password-reset/{{ code }}">
{% csrf_token %}
<div class="field">
<label class="label" for="id_new_password">{% trans "Password:" %}</label>
<label class="label" for="id_new_password">
{% trans "Password:" %}
</label>
<div class="control">
<input type="password" name="password" maxlength="128" class="input" required="" id="id_new_password">
<input type="password" name="password" maxlength="128" class="input" required="" id="id_new_password" aria-describedby="form_errors">
</div>
</div>
<div class="field">
<label class="label" for="id_confirm_password">{% trans "Confirm password:" %}</label>
<label class="label" for="id_confirm_password">
{% trans "Confirm password:" %}
</label>
<div class="control">
<input type="password" name="confirm-password" maxlength="128" class="input" required="" id="id_confirm_password">
<input type="password" name="confirm-password" maxlength="128" class="input" required="" id="id_confirm_password" aria-describedby="form_errors">
</div>
</div>
<div class="field is-grouped">

View file

@ -18,10 +18,9 @@
{% csrf_token %}
<div class="field">
<label class="label" for="id_password">{% trans "Confirm password:" %}</label>
<input class="input {% if form.password.errors %}is-danger{% endif %}" type="password" name="password" id="id_password" required>
{% for error in form.password.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<input class="input {% if form.password.errors %}is-danger{% endif %}" type="password" name="password" id="id_password" required aria-describedby="desc_password">
{% include 'snippets/form_errors.html' with errors_list=form.password.errors id="desc_password" %}
</div>
<button type="submit" class="button is-danger">{% trans "Delete Account" %}</button>
</form>

View file

@ -33,31 +33,27 @@
{% endif %}
<div class="column">
{{ form.avatar }}
{% for error in form.avatar.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.avatar.errors id="desc_avatar" %}
</div>
</div>
<div class="field">
<label class="label" for="id_name">{% trans "Display name:" %}</label>
{{ form.name }}
{% for error in form.name.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.name.errors id="desc_name" %}
</div>
<div class="field">
<label class="label" for="id_summary">{% trans "Summary:" %}</label>
{{ form.summary }}
{% for error in form.summary.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.summary.errors id="desc_summary" %}
</div>
<div class="field">
<label class="label" for="id_email">{% trans "Email address:" %}</label>
{{ form.email }}
{% for error in form.email.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.email.errors id="desc_email" %}
</div>
</div>
</section>
@ -69,19 +65,23 @@
<div class="box">
<div class="field">
<label class="checkbox label" for="id_show_goal">
{% trans "Show reading goal prompt in feed:" %}
{{ form.show_goal }}
{% trans "Show reading goal prompt in feed" %}
</label>
</div>
<div class="field">
<label class="checkbox label" for="id_show_suggested_users">
{% trans "Show suggested users:" %}
{{ form.show_suggested_users }}
{% trans "Show suggested users" %}
</label>
</div>
<div class="field">
<label class="checkbox label" for="id_discoverable">
{% trans "Show this account in suggested users:" %}
{{ form.discoverable }}
{% trans "Show this account in suggested users" %}
</label>
{% url 'directory' as path %}
<p class="help">
<p class="help" id="desc_discoverable">
{% blocktrans %}Your account will show up in the <a href="{{ path }}">directory</a>, and may be recommended to other BookWyrm users.{% endblocktrans %}
</p>
</div>
@ -107,8 +107,8 @@
<div class="box">
<div class="field">
<label class="checkbox label" for="id_manually_approves_followers">
{% trans "Manually approve followers:" %}
{{ form.manually_approves_followers }}
{% trans "Manually approve followers" %}
</label>
</div>
<div class="field">

View file

@ -13,60 +13,68 @@
{% csrf_token %}
<input type="hidden" name="user" value="{{ request.user.id }}">
<p>
<label class="label" for="id_preview">{% trans "Preview:" %}</label>
<label class="label" for="id_preview">
{% trans "Preview:" %}
</label>
{{ form.preview }}
{% for error in form.preview.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.preview.errors id="desc_preview" %}
</p>
<p>
<label class="label" for="id_content">{% trans "Content:" %}</label>
<label class="label" for="id_content">
{% trans "Content:" %}
</label>
{{ form.content }}
{% for error in form.content.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.content.errors id="desc_content" %}
</p>
<p>
<label class="label" for="id_event_date">{% trans "Event date:" %}</label>
<label class="label" for="id_event_date">
{% trans "Event date:" %}
</label>
<input type="date" name="event_date" value="{{ form.event_date.value|date:'Y-m-d' }}" class="input" id="id_event_date">
{% for error in form.event_date.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.event_date.errors id="desc_event_date" %}
</p>
<hr aria-hidden="true">
<div class="columns">
<div class="column">
<p>
<label class="label" for="id_start_date">{% trans "Start date:" %}</label>
<label class="label" for="id_start_date">
{% trans "Start date:" %}
</label>
<input type="date" name="start_date" class="input" value="{{ form.start_date.value|date:'Y-m-d' }}" id="id_start_date">
{% for error in form.start_date.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.start_date.errors id="desc_start_date" %}
</p>
</div>
<div class="column">
<p>
<label class="label" for="id_end_date">{% trans "End date:" %}</label>
<label class="label" for="id_end_date">
{% trans "End date:" %}
</label>
<input type="date" name="end_date" class="input" id="id_end_date" value="{{ form.end_date.value|date:'Y-m-d' }}">
{% for error in form.end_date.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.end_date.errors id="desc_end_date" %}
</p>
</div>
<div class="column is-narrow">
<p>
<label class="label" for="id_active">{% trans "Active:" %}</label>
<label class="label" for="id_active">
{% trans "Active:" %}
</label>
{{ form.active }}
{% for error in form.active.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.active.errors id="desc_active" %}
</p>
</div>
</div>
<div class="field has-addons">
<div class="control">
<button type="submit" class="button is-primary">{% trans "Save" %}</button>
<button type="submit" class="button is-primary">
{% trans "Save" %}
</button>
</div>
</div>
{% endblock %}

View file

@ -17,10 +17,8 @@
{{ form.domain }}
</div>
</div>
{% for error in form.domain.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.domain.errors id="desc_domain" %}
<div class="field">
<div class="control">
<button type="submit" class="button is-primary">{% trans "Add" %}</button>

View file

@ -27,11 +27,12 @@
<div class="columns">
<div class="column is-half">
<div class="field">
<label class="label" for="id_server_name">{% trans "Instance:" %}</label>
<input type="text" name="server_name" maxlength="255" class="input" required id="id_server_name" value="{{ form.server_name.value|default:'' }}" placeholder="domain.com">
{% for error in form.server_name.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<label class="label" for="id_server_name">
{% trans "Instance:" %}
</label>
<input type="text" name="server_name" maxlength="255" class="input" required id="id_server_name" value="{{ form.server_name.value|default:'' }}" placeholder="domain.com" aria-describedby="desc_server_name">
{% include 'snippets/form_errors.html' with errors_list=form.server_name.errors id="desc_server_name" %}
</div>
</div>
<div class="column is-half">
@ -49,29 +50,37 @@
<div class="columns">
<div class="column is-half">
<div class="field">
<label class="label" for="id_application_type">{% trans "Software:" %}</label>
<input type="text" name="application_type" maxlength="255" class="input" id="id_application_type" value="{{ form.application_type.value|default:'' }}">
{% for error in form.application_type.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<label class="label" for="id_application_type">
{% trans "Software:" %}
</label>
<input type="text" name="application_type" maxlength="255" class="input" id="id_application_type" value="{{ form.application_type.value|default:'' }}" aria-describedby="desc_application_type">
{% include 'snippets/form_errors.html' with errors_list=form.application_type.errors id="desc_application_type" %}
</div>
</div>
<div class="column is-half">
<div class="field">
<label class="label" for="id_application_version">{% trans "Version:" %}</label>
<input type="text" name="application_version" maxlength="255" class="input" id="id_application_version" value="{{ form.application_version.value|default:'' }}">
{% for error in form.application_version.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<label class="label" for="id_application_version">
{% trans "Version:" %}
</label>
<input type="text" name="application_version" maxlength="255" class="input" id="id_application_version" value="{{ form.application_version.value|default:'' }}" aria-describedby="desc_application_version">
{% include 'snippets/form_errors.html' with errors_list=form.application_version.errors id="desc_application_version" %}
</div>
</div>
</div>
<div class="field">
<label class="label" for="id_notes">{% trans "Notes:" %}</label>
<textarea name="notes" cols="40" rows="5" class="textarea" id="id_notes">{{ form.notes.value|default:'' }}</textarea>
<label class="label" for="id_notes">
{% trans "Notes:" %}
</label>
<textarea name="notes" cols="40" rows="5" class="textarea" id="id_notes">
{{ form.notes.value|default:'' }}
</textarea>
</div>
<button type="submit" class="button is-primary">{% trans "Save" %}</button>
<button type="submit" class="button is-primary">
{% trans "Save" %}
</button>
</form>
{% endblock %}

View file

@ -20,16 +20,16 @@
</div>
<div class="field">
<input type="text" name="address" maxlength="255" class="input" required="" id="id_address" placeholder="190.0.2.0/24">
<input type="text" name="address" maxlength="255" class="input" required="" id="id_address" placeholder="190.0.2.0/24" aria-describedby="desc_address">
</div>
{% for error in form.address.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=form.address.errors id="desc_address" %}
<div class="field">
<div class="control">
<button type="submit" class="button is-primary">{% trans "Add" %}</button>
<button type="submit" class="button is-primary">
{% trans "Add" %}
</button>
</div>
</div>
</form>

View file

@ -33,8 +33,8 @@
{{ site_form.instance_description }}
</div>
<div class="field">
<label class="label mb-0" for="id_short_description">{% trans "Short description:" %}</label>
<p class="help">{% trans "Used when the instance is previewed on joinbookwyrm.com. Does not support HTML or Markdown." %}</p>
<label class="label mb-0" for="id_instance_short_description">{% trans "Short description:" %}</label>
<p class="help" id="desc_instance_short_description">{% trans "Used when the instance is previewed on joinbookwyrm.com. Does not support HTML or Markdown." %}</p>
{{ site_form.instance_short_description }}
</div>
<div class="field">
@ -114,7 +114,7 @@
{{ site_form.require_confirm_email }}
{% trans "Require users to confirm email address" %}
</label>
<p class="help">{% trans "(Recommended if registration is open)" %}</p>
<p class="help" id="desc_require_confirm_email">{% trans "(Recommended if registration is open)" %}</p>
</div>
<div class="field">
<label class="label" for="id_registration_closed_text">{% trans "Registration closed text:" %}</label>
@ -123,9 +123,8 @@
<div class="field">
<label class="label" for="id_invite_request_text">{% trans "Invite request text:" %}</label>
{{ site_form.invite_request_text }}
{% for error in site_form.invite_request_text.errors %}
<p class="help is-danger">{{ error|escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=site_form.invite_request_text.errors id="desc_invite_request_text" %}
</div>
</div>
</section>

View file

@ -15,10 +15,9 @@
</p>
<div class="field">
<label class="label" for="id_password">{% trans "Your password:" %}</label>
<input class="input {% if form.password.errors %}is-danger{% endif %}" type="password" name="password" id="id_password" required>
{% for error in form.password.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<input class="input {% if form.password.errors %}is-danger{% endif %}" type="password" name="password" id="id_password" required aria-describedby="desc_password">
{% include 'snippets/form_errors.html' with errors_list=form.password.errors id="desc_password" %}
</div>
<button type="submit" class="button is-danger">{% trans "Delete Account" %}</button>
</form>

View file

@ -50,18 +50,23 @@
{% endif %}
{% with group=user.groups.first %}
<div class="select">
<select name="groups" id="id_user_group">
<select name="groups" id="id_user_group" aria-describedby="desc_user_group">
{% for value, name in group_form.fields.groups.choices %}
<option value="{{ value }}" {% if name == group.name %}selected{% endif %}>{{ name|title }}</option>
<option value="{{ value }}" {% if name == group.name %}selected{% endif %}>
{{ name|title }}
</option>
{% endfor %}
<option value="" {% if not group %}selected{% endif %}>User</option>
<option value="" {% if not group %}selected{% endif %}>
User
</option>
</select>
</div>
{% for error in group_form.groups.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
{% include 'snippets/form_errors.html' with errors_list=group_form.groups.errors id="desc_user_group" %}
{% endwith %}
<button class="button">{% trans "Save" %}</button>
<button class="button">
{% trans "Save" %}
</button>
</form>
</div>
{% endif %}

View file

@ -0,0 +1,9 @@
{% if errors_list %}
<div id="{{ id }}">
{% for error in errors_list %}
<p class="help is-danger">
{{ error | escape }}
</p>
{% endfor %}
</div>
{% endif %}

View file

@ -3,32 +3,31 @@
<div class="field">
<label class="label" for="id_localname_register">{% trans "Username:" %}</label>
<div class="control">
<input type="text" name="localname" maxlength="150" class="input" required="" id="id_localname_register" value="{% if register_form.localname.value %}{{ register_form.localname.value }}{% endif %}">
<input type="text" name="localname" maxlength="150" class="input" required="" id="id_localname_register" value="{% if register_form.localname.value %}{{ register_form.localname.value }}{% endif %}" aria-describedby="desc_localname_register">
{% include 'snippets/form_errors.html' with errors_list=register_form.localname.errors id="desc_localname_register" %}
</div>
{% for error in register_form.localname.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
</div>
<div class="field">
<label class="label" for="id_email_register">{% trans "Email address:" %}</label>
<div class="control">
<input type="email" name="email" maxlength="254" class="input" id="id_email_register" value="{% if register_form.email.value %}{{ register_form.email.value }}{% endif %}" required>
{% for error in register_form.email.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<input type="email" name="email" maxlength="254" class="input" id="id_email_register" value="{% if register_form.email.value %}{{ register_form.email.value }}{% endif %}" required aria-describedby="desc_email_register">
{% include 'snippets/form_errors.html' with errors_list=register_form.email.errors id="desc_email_register" %}
</div>
</div>
<div class="field">
<label class="label" for="id_password_register">{% trans "Password:" %}</label>
<div class="control">
<input type="password" name="password" maxlength="128" class="input" required="" id="id_password_register">
{% for error in register_form.password.errors %}
<p class="help is-danger">{{ error | escape }}</p>
{% endfor %}
<input type="password" name="password" maxlength="128" class="input" required="" id="id_password_register" aria-describedby="desc_password_register">
{% include 'snippets/form_errors.html' with errors_list=register_form.password.errors id="desc_password_register" %}
</div>
</div>
<div class="field is-grouped">
<div class="control">
<button class="button is-primary" type="submit">{% trans "Sign Up" %}</button>
<button class="button is-primary" type="submit">
{% trans "Sign Up" %}
</button>
</div>
</div>