Edit book form

This commit is contained in:
Mouse Reeve 2020-04-02 08:44:53 -07:00
parent 2b451f65ab
commit 75a589571c
5 changed files with 15 additions and 9 deletions

View file

@ -29,7 +29,6 @@ def load_more_data(book_id):
connector.expand_book_data(book)
def search(query):
''' try an external datasource for books '''
connector = get_connector()

View file

@ -78,9 +78,9 @@ class CoverForm(ModelForm):
help_texts = {f: None for f in fields}
class BookForm(ModelForm):
class EditionForm(ModelForm):
class Meta:
model = models.Book
model = models.Edition
exclude = [
'created_date',
'updated_date',
@ -91,8 +91,8 @@ class BookForm(ModelForm):
'shelves',
'misc_identifiers',
'subjects',
'subject_places',
'subjects',# TODO
'subject_places',# TODO
'source_url',
'connector',

View file

@ -29,12 +29,19 @@
<h3>Book Identifiers</h2>
<div>
<p><label for="id_isbn">ISBN:</label> {{ form.isbn }} </p>
<p><label for="id_fedireads_key">Fedireads key:</label> {{ form.fedireads_key }} </p>
<p><label for="id_openlibrary_key">Openlibrary key:</label> {{ form.openlibrary_key }} </p>
<p><label for="id_librarything_key">Librarything key:</label> {{ form.librarything_key }} </p>
<p><label for="id_goodreads_key">Goodreads key:</label> {{ form.goodreads_key }} </p>
</div>
<h3>Physical Properties</h3>
<div>
<p><label for="id_physical_format">Format:</label> {{ form.physical_format }} </p>
<p><label for="id_pages">Pages:</label> {{ form.pages }} </p>
</div>
<h3>Metadata</h3>
<div>
<p><label for="id_title">Title:</label> {{ form.title }} </p>

View file

@ -95,11 +95,11 @@ def edit_book(request, book_id):
return redirect('/book/%s' % request.user.localname)
try:
book = models.Book.objects.get(id=book_id)
except models.Book.DoesNotExist:
book = models.Edition.objects.get(id=book_id)
except models.Edition.DoesNotExist:
return HttpResponseNotFound()
form = forms.BookForm(request.POST, request.FILES, instance=book)
form = forms.EditionForm(request.POST, request.FILES, instance=book)
if not form.is_valid():
return redirect(request.headers.get('Referer', '/'))
form.save()

View file

@ -433,7 +433,7 @@ def edit_book_page(request, book_identifier):
book = books_manager.get_or_create_book(book_identifier)
data = {
'book': book,
'form': forms.BookForm(instance=book)
'form': forms.EditionForm(instance=book)
}
return TemplateResponse(request, 'edit_book.html', data)