From af2afa389ea8c6ce216c8149f372eb0baa40f0cd Mon Sep 17 00:00:00 2001 From: George Katsikas <giorgakis.katsikas@gmail.com> Date: Wed, 2 Oct 2024 10:44:17 +0200 Subject: [PATCH] replace children subsidy annotation with property --- scipost_django/organizations/managers.py | 4 +--- scipost_django/organizations/views.py | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/scipost_django/organizations/managers.py b/scipost_django/organizations/managers.py index 8ffb661a0..6ffa96bad 100644 --- a/scipost_django/organizations/managers.py +++ b/scipost_django/organizations/managers.py @@ -138,9 +138,7 @@ class OrganizationQuerySet(models.QuerySet): has_children_with_current_subsidy=Exists( Subsidy.objects.filter(organization__in=models.OuterRef("children")) .obtained() - .filter( - date_until__gte=timezone.now(), - ) + .filter(date_until__gte=timezone.now()) ) ) diff --git a/scipost_django/organizations/views.py b/scipost_django/organizations/views.py index 8c9b30ae5..2838fd09a 100644 --- a/scipost_django/organizations/views.py +++ b/scipost_django/organizations/views.py @@ -270,7 +270,6 @@ class OrganizationListView(PaginationMixin, ListView): qs = ( qs.annot_has_current_subsidy() - .annot_has_children_with_current_subsidy() .annot_has_any_subsidy() .prefetch_related("logos", "children") .select_related("parent") @@ -289,7 +288,8 @@ class OrganizationListView(PaginationMixin, ListView): qs = qs.order_by("cf_balance_info__cumulative__impact_on_reserves") if ordering == "desc": qs = qs.reverse() - return qs.distinct() + + return qs def get_organization_detail(request): -- GitLab