forked from mirrors/bookwyrm
Python formatting
This commit is contained in:
parent
b001c31f97
commit
29a6d74ff2
4 changed files with 14 additions and 11 deletions
|
@ -287,6 +287,7 @@ class EditionFromWorkForm(CustomForm):
|
|||
"first_published_date",
|
||||
]
|
||||
|
||||
|
||||
class EditionForm(CustomForm):
|
||||
class Meta:
|
||||
model = models.Edition
|
||||
|
|
|
@ -496,7 +496,9 @@ urlpatterns = [
|
|||
),
|
||||
re_path(rf"{BOOK_PATH}/edit/?$", views.EditBook.as_view(), name="edit-book"),
|
||||
re_path(rf"{BOOK_PATH}/confirm/?$", views.ConfirmEditBook.as_view()),
|
||||
re_path(r"^create-book/data/?$", views.create_book_from_data, name="create-book-data"),
|
||||
re_path(
|
||||
r"^create-book/data/?$", views.create_book_from_data, name="create-book-data"
|
||||
),
|
||||
re_path(r"^create-book/?$", views.CreateBook.as_view(), name="create-book"),
|
||||
re_path(r"^create-book/confirm/?$", views.ConfirmEditBook.as_view()),
|
||||
re_path(rf"{BOOK_PATH}/editions(.json)?/?$", views.Editions.as_view()),
|
||||
|
|
|
@ -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)}
|
||||
|
|
Loading…
Reference in a new issue