diff --git a/bookwyrm/migrations/0013_book_origin_id.py b/bookwyrm/migrations/0013_book_origin_id.py new file mode 100644 index 000000000..581a2406e --- /dev/null +++ b/bookwyrm/migrations/0013_book_origin_id.py @@ -0,0 +1,18 @@ +# Generated by Django 3.0.7 on 2020-11-24 21:42 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('bookwyrm', '0012_attachment'), + ] + + operations = [ + migrations.AlterField( + model_name='book', + name='origin_id', + field=models.CharField(blank=True, max_length=255, null=True), + ), + ] diff --git a/bookwyrm/models/book.py b/bookwyrm/models/book.py index 6edfece80..c8643f07e 100644 --- a/bookwyrm/models/book.py +++ b/bookwyrm/models/book.py @@ -16,7 +16,7 @@ from .base_model import image_attachments_formatter class Book(ActivitypubMixin, BookWyrmModel): ''' a generic book, which can mean either an edition or a work ''' - origin_id = models.CharField(max_length=255, null=True) + origin_id = models.CharField(max_length=255, null=True, blank=True) # these identifiers apply to both works and editions openlibrary_key = models.CharField(max_length=255, blank=True, null=True) librarything_key = models.CharField(max_length=255, blank=True, null=True) diff --git a/bookwyrm/templates/edit_book.html b/bookwyrm/templates/edit_book.html index bd89ac0a9..54cefb0a7 100644 --- a/bookwyrm/templates/edit_book.html +++ b/bookwyrm/templates/edit_book.html @@ -20,6 +20,12 @@ +{% if login_form.non_field_errors %} +
+

{{ login_form.non_field_errors }}

+
+{% endif %} +
{% csrf_token %}
@@ -37,13 +43,40 @@
-
-

Book Identifiers

-

{{ form.isbn_13 }}

-

{{ form.isbn_10 }}

-

{{ form.openlibrary_key }}

-

{{ form.librarything_key }}

-

{{ form.goodreads_key }}

+
+

Metadata

+

{{ form.title }}

+ {% for error in form.title.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.sort_title }}

+ {% for error in form.sort_title.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.subtitle }}

+ {% for error in form.subtitle.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.description }}

+ {% for error in form.description.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.series }}

+ {% for error in form.series.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.series_number }}

+ {% for error in form.series_number.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.first_published_date }}

+ {% for error in form.first_published_date.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.published_date }}

+ {% for error in form.published_date.errors %} +

{{ error | escape }}

+ {% endfor %}
@@ -55,6 +88,9 @@

Cover

{{ form.cover }}

+ {% for error in form.cover.errors %} +

{{ error | escape }}

+ {% endfor %}
@@ -62,22 +98,45 @@

Physical Properties

{{ form.physical_format }}

+ {% for error in form.physical_format.errors %} +

{{ error | escape }}

+ {% endfor %} + {% for error in form.physical_format.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.pages }}

+ {% for error in form.pages.errors %} +

{{ error | escape }}

+ {% endfor %} +
+ +
+

Book Identifiers

+

{{ form.isbn_13 }}

+ {% for error in form.isbn_13.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.isbn_10 }}

+ {% for error in form.isbn_10.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.openlibrary_key }}

+ {% for error in form.openlibrary_key.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.librarything_key }}

+ {% for error in form.librarything_key.errors %} +

{{ error | escape }}

+ {% endfor %} +

{{ form.goodreads_key }}

+ {% for error in form.goodreads_key.errors %} +

{{ error | escape }}

+ {% endfor %}
-
-

Metadata

-

{{ form.title }}

-

{{ form.sort_title }}

-

{{ form.subtitle }}

-

{{ form.description }}

-

{{ form.series }}

-

{{ form.series_number }}

-

{{ form.first_published_date }}

-

{{ form.published_date }}

-
Cancel @@ -85,4 +144,3 @@ {% endblock %} - diff --git a/bookwyrm/view_actions.py b/bookwyrm/view_actions.py index b7e92c89f..ad9a12cf7 100644 --- a/bookwyrm/view_actions.py +++ b/bookwyrm/view_actions.py @@ -235,7 +235,12 @@ def edit_book(request, book_id): form = forms.EditionForm(request.POST, request.FILES, instance=book) if not form.is_valid(): - return redirect(request.headers.get('Referer', '/')) + data = { + 'title': 'Edit Book', + 'book': book, + 'form': form + } + return TemplateResponse(request, 'edit_book.html', data) form.save() outgoing.handle_update_book(request.user, book)