mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-11-27 03:51:08 +00:00
Edit book form
This commit is contained in:
parent
2b451f65ab
commit
75a589571c
5 changed files with 15 additions and 9 deletions
|
@ -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()
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue