mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-24 07:58:08 +00:00
Sort author books by rating
This commit is contained in:
parent
f1f7b21d43
commit
8ca2b55e7e
1 changed files with 3 additions and 2 deletions
|
@ -1,7 +1,7 @@
|
||||||
""" the good people stuff! the authors! """
|
""" the good people stuff! the authors! """
|
||||||
from django.contrib.auth.decorators import login_required, permission_required
|
from django.contrib.auth.decorators import login_required, permission_required
|
||||||
from django.core.paginator import Paginator
|
from django.core.paginator import Paginator
|
||||||
from django.db.models import Q
|
from django.db.models import Avg, Q
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.template.response import TemplateResponse
|
from django.template.response import TemplateResponse
|
||||||
from django.utils.decorators import method_decorator
|
from django.utils.decorators import method_decorator
|
||||||
|
@ -28,7 +28,8 @@ class Author(View):
|
||||||
|
|
||||||
books = (
|
books = (
|
||||||
models.Work.objects.filter(Q(authors=author) | Q(editions__authors=author))
|
models.Work.objects.filter(Q(authors=author) | Q(editions__authors=author))
|
||||||
.order_by("-published_date")
|
.annotate(Avg("editions__review__rating"))
|
||||||
|
.order_by("editions__review__rating__avg")
|
||||||
.distinct()
|
.distinct()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue