From 63d31b8623d5eb084b049b5acbf8ae0a91da8408 Mon Sep 17 00:00:00 2001 From: Joachim Date: Mon, 29 Nov 2021 23:29:22 +0100 Subject: [PATCH] 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 e8136a54f..3f46be348 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 982bb56d2..feebb803c 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" %} +

{% if book.authors.exists %}
{% for author in book.authors.all %}
-

+

{% blocktrans with name=author.name %}Author page for {{ name }}{% endblocktrans %}

@@ -119,9 +138,13 @@
{% endif %}
- - - {% trans "Separate multiple values with commas." %} + + + + {% trans "Separate multiple values with commas." %} +
@@ -129,7 +152,9 @@
-

{% trans "Cover" %}

+

+ {% trans "Cover" %} +

{% if book.cover %} @@ -140,108 +165,122 @@
- + {{ form.cover }}
- +
- {% for error in form.cover.errors %} -

{{ error | escape }}

- {% endfor %} + + {% include 'snippets/form_errors.html' with errors_list=form.cover.errors id="desc_cover" %}
-

{% 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" %}