mirror of
https://github.com/ae-utbm/sith.git
synced 2026-05-22 08:50:17 +00:00
add club links to club list page
This commit is contained in:
@@ -69,6 +69,18 @@
|
|||||||
{{ club.name }} {% if not club.is_active %}({% trans %}inactive{% endtrans %}){% endif %}
|
{{ club.name }} {% if not club.is_active %}({% trans %}inactive{% endtrans %}){% endif %}
|
||||||
</h4>
|
</h4>
|
||||||
</a>
|
</a>
|
||||||
|
{% set links = club.links.all() %}
|
||||||
|
{% if links %}
|
||||||
|
<br>
|
||||||
|
<div class="row gap-2x">
|
||||||
|
{% for link in club.links.all() %}
|
||||||
|
<a href="{{ link.url }}">
|
||||||
|
<i class="{{ link.link_type.icon }} fa-xl"></i>
|
||||||
|
<strong>{{ link.name }}</strong>
|
||||||
|
</a>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
{{ club.short_description|markdown }}
|
{{ club.short_description|markdown }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+6
-8
@@ -36,7 +36,7 @@ from django.contrib.auth.mixins import (
|
|||||||
from django.contrib.messages.views import SuccessMessageMixin
|
from django.contrib.messages.views import SuccessMessageMixin
|
||||||
from django.core.exceptions import NON_FIELD_ERRORS, PermissionDenied, ValidationError
|
from django.core.exceptions import NON_FIELD_ERRORS, PermissionDenied, ValidationError
|
||||||
from django.core.paginator import InvalidPage, Paginator
|
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.db.models.functions import Length
|
||||||
from django.http import Http404, StreamingHttpResponse
|
from django.http import Http404, StreamingHttpResponse
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
@@ -48,12 +48,7 @@ from django.utils.translation import gettext
|
|||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from django.views.generic import DetailView, ListView, View
|
from django.views.generic import DetailView, ListView, View
|
||||||
from django.views.generic.detail import SingleObjectMixin
|
from django.views.generic.detail import SingleObjectMixin
|
||||||
from django.views.generic.edit import (
|
from django.views.generic.edit import CreateView, DeleteView, FormMixin, UpdateView
|
||||||
CreateView,
|
|
||||||
DeleteView,
|
|
||||||
FormMixin,
|
|
||||||
UpdateView,
|
|
||||||
)
|
|
||||||
|
|
||||||
from club.forms import (
|
from club.forms import (
|
||||||
ClubAddMemberForm,
|
ClubAddMemberForm,
|
||||||
@@ -69,6 +64,7 @@ from club.forms import (
|
|||||||
)
|
)
|
||||||
from club.models import (
|
from club.models import (
|
||||||
Club,
|
Club,
|
||||||
|
ClubLink,
|
||||||
ClubRole,
|
ClubRole,
|
||||||
LinkType,
|
LinkType,
|
||||||
Mailing,
|
Mailing,
|
||||||
@@ -218,7 +214,9 @@ class ClubListView(AllowFragment, FormMixin, ListView):
|
|||||||
|
|
||||||
template_name = "club/club_list.jinja"
|
template_name = "club/club_list.jinja"
|
||||||
form_class = ClubSearchForm
|
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
|
paginate_by = 20
|
||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user