diff --git a/scipost_django/organizations/models.py b/scipost_django/organizations/models.py index 6e39ddac12de17277f79a25b8881d3f0a146c460..426f0017a93f8593fddff478d839a7b57921d4f6 100644 --- a/scipost_django/organizations/models.py +++ b/scipost_django/organizations/models.py @@ -322,7 +322,13 @@ class Organization(models.Model): rep[str(year)] = {} year_expenditures = 0 rep[str(year)]["expenditures"] = {} - pfy = self.pubfractions.filter(publication__publication_date__year=year) + pfy = self.pubfractions.filter( + publication__publication_date__year=year + ).prefetch_related( + "publication__in_journal", + "publication__in_issue__in_journal", + "publication__in_issue__in_volume__in_journal", + ) contribution = self.total_subsidies_in_year(year) rep[str(year)]["contribution"] = contribution journal_labels = set( diff --git a/scipost_django/organizations/templates/organizations/_organization_detail_contents.html b/scipost_django/organizations/templates/organizations/_organization_detail_contents.html index fea574327b9a82ca599e9148efdee758b86dff29..7c1bf8c914e32d292eb214e2262f8758f9c53c87 100644 --- a/scipost_django/organizations/templates/organizations/_organization_detail_contents.html +++ b/scipost_django/organizations/templates/organizations/_organization_detail_contents.html @@ -51,6 +51,7 @@ {% endfor %} <img class="rounded" style="max-height: 8rem; max-width: 16rem;" src="{{ org.logo.url }}" alt="{{ org.name }} logo"> + </picture> </li> {% elif org.logo %} <img class="d-flex me-3 {{ org.css_class }}" src="{{ org.logo.url }}" alt="image"/> diff --git a/scipost_django/organizations/views.py b/scipost_django/organizations/views.py index c432bbd2da2c060a827d71e59ac3186236cbae49..e66cc0d786c50cb1af2604b2af95095bc8c66688 100644 --- a/scipost_django/organizations/views.py +++ b/scipost_django/organizations/views.py @@ -166,7 +166,7 @@ class OrganizationListView(PaginationMixin, ListView): ) if ordering == "desc": qs = qs.reverse() - return qs + return qs.select_related('logos') def get_organization_detail(request): @@ -194,7 +194,13 @@ class OrganizationDetailView(DetailView): queryset = super().get_queryset() if not self.request.user.has_perm("scipost.can_manage_organizations"): queryset = queryset.exclude(orgtype=ORGTYPE_PRIVATE_BENEFACTOR) - return queryset + return queryset.prefetch_related( + "children", + "subsidy_set", + "contactrole_set", + "organizationevent_set", + "pubfractions", + ) class OrganizationEventCreateView(PermissionsMixin, CreateView):