SMall fixes for update form and ol connector

This commit is contained in:
Mouse Reeve 2020-04-04 13:46:10 -07:00
parent 630c94a34a
commit f0609e6ff3
3 changed files with 9 additions and 8 deletions

View file

@ -48,13 +48,11 @@ class Connector(AbstractConnector):
if you give a work key, it should give you the default edition,
annotated with work data. '''
try:
book = models.Book.objects.select_subclasses().filter(
openlibrary_key=olkey
).first()
book = models.Book.objects.select_subclasses().filter(
openlibrary_key=olkey
).first()
if book:
return book
except ObjectDoesNotExist:
pass
# no book was found, so we start creating a new one
model = models.Edition
if re.match(r'^OL\d+W$', olkey):
@ -122,7 +120,6 @@ class Connector(AbstractConnector):
if not data.get('authors') and book.parent_work.authors.count():
book.authors.set(book.parent_work.authors.all())
if book.sync_cover and data.get('covers') and len(data['covers']):
book.cover.save(*self.get_cover(data['covers'][0]), save=True)

View file

@ -59,12 +59,14 @@
<p><label for="id_sort_title">Sort title:</label> {{ form.sort_title }} </p>
<p><label for="id_subtitle">Subtitle:</label> {{ form.subtitle }} </p>
<p><label for="id_description">Description:</label> {{ form.description }} </p>
<p><label for="id_language">Language:</label> {{ form.language }} </p>
<p><label for="id_series">Series:</label> {{ form.series }} </p>
<p><label for="id_series_number">Series number:</label> {{ form.series_number }} </p>
<p><label for="id_first_published_date">First published date:</label> {{ form.first_published_date }} </p>
<p><label for="id_published_date">Published date:</label> {{ form.published_date }} </p>
</div>
<div>
<button type="submit">Save</button>
</div>
</form>
{% endblock %}

View file

@ -426,6 +426,8 @@ def book_page(request, book_identifier, tab='friends'):
def edit_book_page(request, book_identifier):
''' info about a book '''
book = books_manager.get_or_create_book(book_identifier)
if not book.description:
book.description = book.parent_work.description
data = {
'book': book,
'form': forms.EditionForm(instance=book)