Skip to content

Commit

Permalink
show partner if exists in documentation forum detail view
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Sep 3, 2024
1 parent 810e2d4 commit eb0ebb1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lacommunaute/forum/tests/__snapshots__/tests_views.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,21 @@
</div>
'''
# ---
# name: TestDocumentationForumContent.test_documentation_forum_with_partner[documentation_forum_with_partner]
'''
[<div class="col-12 col-sm-auto mt-3" id="partner_area">
<a href="/partners/best-partner-ever-[PK of Partner]/">
<div class="d-flex gap-3 align-items-center mb-2">

<img alt="Best Partner Ever" class="img-fluid" loading="lazy" src="[img src]" width="100"/>

<h4>Fiche co-rédigée en partenariat avec Best Partner Ever</h4>
</div>
</a>

</div>]
'''
# ---
# name: TestForumDetailContent.test_forum_detail_foot_content[forum_detail_forum_actions_block]
'''
<div class="col-12 col-sm-auto forum-actions-block">
Expand Down
8 changes: 8 additions & 0 deletions lacommunaute/forum/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from lacommunaute.forum_conversation.factories import CertifiedPostFactory, PostFactory, TopicFactory
from lacommunaute.forum_conversation.forms import PostForm
from lacommunaute.forum_conversation.models import Topic
from lacommunaute.partner.factories import PartnerFactory
from lacommunaute.users.factories import UserFactory
from lacommunaute.utils.testing import parse_response_to_soup, reset_model_sequence_fixture

Expand Down Expand Up @@ -641,6 +642,13 @@ def test_documentation_forum_header_content(self, client, db, snapshot, reset_fo

assert len(content.find_all("a", href=sibling_forum.get_absolute_url())) == 1

def test_documentation_forum_with_partner(self, client, db, snapshot, documentation_forum):
documentation_forum.partner = PartnerFactory(for_snapshot=True, with_logo=True)
documentation_forum.save()
response = client.get(documentation_forum.get_absolute_url())
content = parse_response_to_soup(response, replace_in_href=[documentation_forum.partner], replace_img_src=True)
assert str(content.select("#partner_area")) == snapshot(name="documentation_forum_with_partner")


class TestDocumentationCategoryForumContent:
def test_documentation_category_subforum_list(
Expand Down
5 changes: 5 additions & 0 deletions lacommunaute/templates/forum/forum_documentation.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<div class="col-12 col-sm-auto mt-3">
<article class="textarea_cms_md">{{ forum.description.rendered|urlizetrunc_target_blank:30|img_fluid }}</article>
</div>
{% if forum.partner %}
<div class="col-12 col-sm-auto mt-3" id="partner_area">
{% include "forum/partials/partner.html" with partner=forum.partner only %}
</div>
{% endif %}
{% include "forum/partials/rating.html" with forum=forum rating_area_id="1" %}
</div>
</div>
Expand Down
8 changes: 8 additions & 0 deletions lacommunaute/templates/forum/partials/partner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<a href="{{ partner.get_absolute_url }}">
<div class="d-flex gap-3 align-items-center mb-2">
{% if partner.logo %}
<img src="{{ partner.logo.url }}" alt="{{ partner.name }}" class="img-fluid" width="100" loading="lazy" />
{% endif %}
<h4>Fiche co-rédigée en partenariat avec {{ partner.name }}</h4>
</div>
</a>

0 comments on commit eb0ebb1

Please sign in to comment.