mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-22 08:07:14 +00:00
chore: formatting
This commit is contained in:
parent
59a8098517
commit
e0505722e1
1 changed files with 9 additions and 4 deletions
|
@ -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 = {
|
||||
|
|
Loading…
Reference in a new issue