Skip to content

Commit

Permalink
(forum): display image as banner in ForumView
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed May 22, 2024
1 parent 9e5dbff commit 027617e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lacommunaute/forum/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,3 +421,9 @@ def test_filtered_queryset_on_tag(self):
)
self.assertContains(response, topic.subject)
self.assertNotContains(response, self.topic.subject)

def test_banner_display_on_subcategory_forum(self):
category_forum = CategoryForumFactory(with_child=True, with_public_perms=True)
forum = category_forum.get_children().first()
response = self.client.get(reverse("forum_extension:forum", kwargs={"pk": forum.pk, "slug": forum.slug}))
self.assertContains(response, forum.image.url.split("=")[0])
3 changes: 2 additions & 1 deletion lacommunaute/templates/forum/forum_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ <h1>{{ forum.name }}</h1>
{% include "partials/upvotes.html" with obj=forum kind="forum" %}
{% include "partials/social_share_buttons.html" with text=forum.name instance=forum id=forum.pk %}
</div>
<div class="col-12 col-sm-auto">
<div class="col-12 col-sm-auto">{% include "forum/partials/forum_banner.html" with forum=forum only %}</div>
<div class="col-12 col-sm-auto mt-3">
<div class="textarea_cms_md">{{ forum.description.rendered|urlizetrunc_target_blank:30 }}</div>
</div>
</div>
Expand Down
5 changes: 5 additions & 0 deletions lacommunaute/templates/forum/partials/forum_banner.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{% if forum.image %}
<div class="d-none d-md-block forum-image mt-3">
<img src="{{ forum.image.url }}" alt="{{ forum.name }}" class="rounded img-fluid" />
</div>
{% endif %}

0 comments on commit 027617e

Please sign in to comment.