diff --git a/club/templates/club/club_list.jinja b/club/templates/club/club_list.jinja index 8ae08bf3..2018785e 100644 --- a/club/templates/club/club_list.jinja +++ b/club/templates/club/club_list.jinja @@ -62,6 +62,18 @@ {{ club.name }} {% if not club.is_active %}({% trans %}inactive{% endtrans %}){% endif %} + {% set links = club.links.all() %} + {% if links %} +
+
+ {% for link in club.links.all() %} + + + {{ link.name }} + + {% endfor %} +
+ {% endif %} {{ club.short_description|markdown }} diff --git a/club/views.py b/club/views.py index 297fe201..238eb676 100644 --- a/club/views.py +++ b/club/views.py @@ -32,7 +32,7 @@ from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMix from django.contrib.messages.views import SuccessMessageMixin from django.core.exceptions import NON_FIELD_ERRORS, PermissionDenied, ValidationError from django.core.paginator import InvalidPage, Paginator -from django.db.models import F, Q, Sum +from django.db.models import F, Prefetch, Q, Sum from django.db.models.functions import Length from django.http import Http404, StreamingHttpResponse from django.shortcuts import get_object_or_404, redirect @@ -61,7 +61,14 @@ from club.forms import ( MailingForm, SellingsForm, ) -from club.models import Club, LinkType, Mailing, MailingSubscription, Membership +from club.models import ( + Club, + ClubLink, + LinkType, + Mailing, + MailingSubscription, + Membership, +) from com.models import Poster from com.views import ( PosterCreateBaseView, @@ -205,7 +212,9 @@ class ClubListView(AllowFragment, FormMixin, ListView): template_name = "club/club_list.jinja" form_class = ClubSearchForm - queryset = Club.objects.order_by("name") + queryset = Club.objects.prefetch_related( + Prefetch("links", queryset=ClubLink.objects.select_related("link_type")) + ).order_by("name") paginate_by = 20 def get_form_kwargs(self):