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) connector.expand_book_data(book)
def search(query): def search(query):
''' try an external datasource for books ''' ''' try an external datasource for books '''
connector = get_connector() connector = get_connector()

View file

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

View file

@ -29,12 +29,19 @@
<h3>Book Identifiers</h2> <h3>Book Identifiers</h2>
<div> <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_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_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_librarything_key">Librarything key:</label> {{ form.librarything_key }} </p>
<p><label for="id_goodreads_key">Goodreads key:</label> {{ form.goodreads_key }} </p> <p><label for="id_goodreads_key">Goodreads key:</label> {{ form.goodreads_key }} </p>
</div> </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> <h3>Metadata</h3>
<div> <div>
<p><label for="id_title">Title:</label> {{ form.title }} </p> <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) return redirect('/book/%s' % request.user.localname)
try: try:
book = models.Book.objects.get(id=book_id) book = models.Edition.objects.get(id=book_id)
except models.Book.DoesNotExist: except models.Edition.DoesNotExist:
return HttpResponseNotFound() 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(): if not form.is_valid():
return redirect(request.headers.get('Referer', '/')) return redirect(request.headers.get('Referer', '/'))
form.save() form.save()

View file

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