From 28db3e2733d57e9b7a5988e22d2e6c376587496a Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Thu, 11 Mar 2021 16:40:35 -0800 Subject: [PATCH] Formatting --- bookwyrm/views/books.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/bookwyrm/views/books.py b/bookwyrm/views/books.py index ff0d6764..1cb21f5e 100644 --- a/bookwyrm/views/books.py +++ b/bookwyrm/views/books.py @@ -131,22 +131,24 @@ class EditBook(View): # we're adding an author through a free text field if add_author: data["add_author"] = add_author - data['author_matches'] = [] - for author in add_author.split(','): + data["author_matches"] = [] + for author in add_author.split(","): # check for existing authors vector = SearchVector("name", weight="A") + SearchVector( "aliases", weight="B" ) - data["author_matches"].append({ - 'name': author.strip(), - 'matches': ( - models.Author.objects.annotate(search=vector) - .annotate(rank=SearchRank(vector, add_author)) - .filter(rank__gt=0.4) - .order_by("-rank")[:5] - ) - }) + data["author_matches"].append( + { + "name": author.strip(), + "matches": ( + models.Author.objects.annotate(search=vector) + .annotate(rank=SearchRank(vector, add_author)) + .filter(rank__gt=0.4) + .order_by("-rank")[:5] + ), + } + ) # we're creating a new book if not book: @@ -197,16 +199,14 @@ class ConfirmEditBook(View): # get or create author as needed if request.POST.get("add_author"): - for (i, author) in enumerate(request.POST.get("add_author").split(',')): + for (i, author) in enumerate(request.POST.get("add_author").split(",")): match = request.POST.get("author_match-%d" % i) if match and match != "0": author = get_object_or_404( models.Author, id=request.POST["author_match-%d" % i] ) else: - author = models.Author.objects.create( - name=author.strip() - ) + author = models.Author.objects.create(name=author.strip()) book.authors.add(author) # create work, if needed