From e0505722e10ca4ab5089347e916bde39a66ee515 Mon Sep 17 00:00:00 2001 From: Dustin Steiner Date: Mon, 30 Jan 2023 14:45:30 +0000 Subject: [PATCH] chore: formatting --- bookwyrm/views/books/series.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bookwyrm/views/books/series.py b/bookwyrm/views/books/series.py index 6e295a4e9..23ec924a5 100644 --- a/bookwyrm/views/books/series.py +++ b/bookwyrm/views/books/series.py @@ -21,17 +21,19 @@ class BookSeriesBy(View): author = get_object_or_404(models.Author, id=author_id) results = models.Edition.objects.filter(authors=author, series=series_name) - + # when there are multiple editions of the same work, pick the one with a series number or closest work_ids = results.values_list("parent_work__id", flat=True).distinct() - + # filter out multiple editions of the same work numbered_books = [] dated_books = [] unsortable_books = [] for work_id in set(work_ids): result = ( - results.filter(parent_work=work_id).order_by("series_number", "-edition_rank").first() + results.filter(parent_work=work_id) + .order_by("series_number", "-edition_rank") + .first() ) if result.series_number: numbered_books.append(result) @@ -48,7 +50,10 @@ class BookSeriesBy(View): if book.first_published_date else book.published_date, ) - + sorted(unsortable_books, key=lambda book: book.sort_title if book.sort_title else book.title) + + sorted( + unsortable_books, + key=lambda book: book.sort_title if book.sort_title else book.title, + ) ) data = {