+ + + + + +
+ +
+ + + + +
+
+
+
+
+ + Best Partner Ever + +

Best Partner Ever

+
+ +

short description for SEO

+
+
+
+
+
+
+
+
+

h3 long MD description

+ +

lorem ipsum dolor sit amet, consectetur adipiscing elit.

+ + + +
+
+ +
+
+

Leurs contributions dans la communauté

+
+
+ +
+ +
+ +
+
+
+
diff --git a/lacommunaute/partner/tests/tests_partner_detailview.py b/lacommunaute/partner/tests/tests_partner_detailview.py index b00a572b..1fd5473e 100644 --- a/lacommunaute/partner/tests/tests_partner_detailview.py +++ b/lacommunaute/partner/tests/tests_partner_detailview.py @@ -1,5 +1,6 @@ import pytest # noqa +from lacommunaute.forum.factories import ForumFactory from lacommunaute.partner.factories import PartnerFactory from lacommunaute.users.factories import UserFactory from lacommunaute.utils.testing import parse_response_to_soup @@ -23,3 +24,13 @@ def test_partner_detailview(client, db, snapshot, user, snapshot_name): assert str( parse_response_to_soup(response, selector="main", replace_img_src=True, replace_in_href=[partner]) ) == snapshot(name=snapshot_name) + + +def test_partner_with_forums(client, db, snapshot): + partner = PartnerFactory(for_snapshot=True, with_logo=True) + forum = ForumFactory(with_partner=partner, with_public_perms=True, with_tags=["sun", "moon"], for_snapshot=True) + response = client.get(partner.get_absolute_url()) + assert response.status_code == 200 + assert str( + parse_response_to_soup(response, selector="main", replace_img_src=True, replace_in_href=[forum]) + ) == snapshot(name="partner_detailview_with_forums") diff --git a/lacommunaute/partner/views.py b/lacommunaute/partner/views.py index 0f45646a..19a03f9e 100644 --- a/lacommunaute/partner/views.py +++ b/lacommunaute/partner/views.py @@ -1,8 +1,13 @@ from django.views.generic import DetailView, ListView +from machina.core.loading import get_class +from lacommunaute.forum.models import Forum from lacommunaute.partner.models import Partner +ForumVisibilityContentTree = get_class("forum.visibility", "ForumVisibilityContentTree") + + class PartnerListView(ListView): model = Partner template_name = "partner/list.html" @@ -14,3 +19,13 @@ class PartnerDetailView(DetailView): model = Partner template_name = "partner/detail.html" context_object_name = "partner" + + def get_context_data(self, **kwargs): + context = super().get_context_data(**kwargs) + context["sub_forums"] = ForumVisibilityContentTree.from_forums( + self.request.forum_permission_handler.forum_list_filter( + Forum.objects.filter(partner=self.object), + self.request.user, + ), + ) + return context diff --git a/lacommunaute/templates/partner/detail.html b/lacommunaute/templates/partner/detail.html index 7ab79f32..1625c19c 100644 --- a/lacommunaute/templates/partner/detail.html +++ b/lacommunaute/templates/partner/detail.html @@ -38,6 +38,14 @@

{{ partner.short_description }}

{% endif %} + {% if sub_forums %} +
+
+

Leurs contributions dans la communauté

+
+
{% include "forum/partials/category_subforums_list.html" with sub_forums=sub_forums only %}
+
+ {% endif %} {% endblock content %}