Python formatting
This commit is contained in:
@ -37,7 +37,12 @@ from .books.books import (
|
||||
resolve_book,
|
||||
)
|
||||
from .books.books import update_book_from_remote
|
||||
from .books.edit_book import EditBook, ConfirmEditBook, CreateBook, create_book_from_data
|
||||
from .books.edit_book import (
|
||||
EditBook,
|
||||
ConfirmEditBook,
|
||||
CreateBook,
|
||||
create_book_from_data,
|
||||
)
|
||||
from .books.editions import Editions, switch_edition
|
||||
from .books.links import BookFileLinks, AddFileLink, delete_link
|
||||
|
||||
|
@ -157,9 +157,7 @@ class CreateBook(View):
|
||||
if request.POST.get("authors"):
|
||||
author_ids = findall(r"\d+", request.POST["authors"])
|
||||
# django can't parse the authors form element
|
||||
book.authors.add(
|
||||
*models.Author.objects.filter(id__in=author_ids)
|
||||
)
|
||||
book.authors.add(*models.Author.objects.filter(id__in=author_ids))
|
||||
|
||||
url = request.POST.get("cover-url")
|
||||
if url:
|
||||
@ -169,6 +167,7 @@ class CreateBook(View):
|
||||
book.save()
|
||||
return redirect(f"/book/{book.id}")
|
||||
|
||||
|
||||
def add_authors(request, data):
|
||||
"""helper for adding authors"""
|
||||
add_author = [author for author in request.POST.getlist("add_author") if author]
|
||||
@ -184,9 +183,7 @@ def add_authors(request, data):
|
||||
if not author:
|
||||
continue
|
||||
# check for existing authors
|
||||
vector = SearchVector("name", weight="A") + SearchVector(
|
||||
"aliases", weight="B"
|
||||
)
|
||||
vector = SearchVector("name", weight="A") + SearchVector("aliases", weight="B")
|
||||
|
||||
author_matches = (
|
||||
models.Author.objects.annotate(search=vector)
|
||||
@ -229,9 +226,7 @@ def create_book_from_data(request):
|
||||
author_ids = findall(r"\d+", request.POST.get("authors"))
|
||||
book = {
|
||||
"parent_work": {"id": request.POST.get("parent_work")},
|
||||
"authors": models.Author.objects.filter(
|
||||
id__in=author_ids
|
||||
).all(),
|
||||
"authors": models.Author.objects.filter(id__in=author_ids).all(),
|
||||
}
|
||||
|
||||
data = {"book": book, "form": forms.EditionForm(request.POST)}
|
||||
|
Reference in New Issue
Block a user