mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-30 03:50:40 +00:00
fixes book reviews queryset aggregators
This commit is contained in:
parent
779581c6f4
commit
a5ee535ab6
3 changed files with 16 additions and 15 deletions
|
@ -122,7 +122,8 @@ class ViewsHelpers(TestCase):
|
|||
self.assertEqual(statuses[1], public_status)
|
||||
self.assertEqual(statuses[0], rat_public)
|
||||
|
||||
statuses = views.helpers.get_activity_feed(self.local_user, 'direct')
|
||||
statuses = views.helpers.get_activity_feed(
|
||||
self.local_user, privacy=['direct'])
|
||||
self.assertEqual(len(statuses), 1)
|
||||
self.assertEqual(statuses[0], direct_status)
|
||||
|
||||
|
|
|
@ -45,13 +45,9 @@ class Book(View):
|
|||
if not work:
|
||||
return HttpResponseNotFound()
|
||||
|
||||
reviews = models.Review.objects.filter(
|
||||
book__in=work.editions.all(),
|
||||
)
|
||||
# all reviews for the book
|
||||
reviews = get_activity_feed(
|
||||
request.user, queryset=reviews
|
||||
)
|
||||
reviews = models.Review.objects.filter(book__in=work.editions.all())
|
||||
reviews = get_activity_feed(request.user, queryset=reviews)
|
||||
|
||||
# the reviews to show
|
||||
paginated = Paginator(reviews.exclude(
|
||||
|
|
|
@ -117,7 +117,7 @@ def get_activity_feed(
|
|||
user, privacy=None, local_only=False, following_only=False,
|
||||
queryset=None):
|
||||
''' get a filtered queryset of statuses '''
|
||||
if not queryset:
|
||||
if queryset is None:
|
||||
queryset = models.Status.objects.select_subclasses()
|
||||
|
||||
# exclude deleted
|
||||
|
@ -137,6 +137,7 @@ def get_activity_feed(
|
|||
generatednote__isnull=True,
|
||||
)
|
||||
else:
|
||||
try:
|
||||
queryset = queryset.exclude(
|
||||
review__isnull=True,
|
||||
comment__isnull=True,
|
||||
|
@ -144,6 +145,9 @@ def get_activity_feed(
|
|||
generatednote__isnull=True,
|
||||
privacy='direct'
|
||||
)
|
||||
except FieldError:
|
||||
# if we're looking at a subtype of Status (like Review)
|
||||
pass
|
||||
|
||||
# filter for only local status
|
||||
if local_only:
|
||||
|
|
Loading…
Reference in a new issue