Skip to content

Commit

Permalink
(forum): display image as banner in card in list of subforums
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed May 23, 2024
1 parent 9c3bcbf commit 4b68827
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
11 changes: 10 additions & 1 deletion lacommunaute/forum/tests/test_categoryforum_listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pytest_django.asserts import assertContains, assertNotContains

from lacommunaute.forum.enums import Kind as ForumKind
from lacommunaute.forum.factories import ForumFactory
from lacommunaute.forum.factories import CategoryForumFactory, ForumFactory
from lacommunaute.forum.models import Forum
from lacommunaute.users.factories import UserFactory

Expand Down Expand Up @@ -45,3 +45,12 @@ def test_display_create_category_button(client, db):
user.save()
response = client.get(url)
assertContains(response, reverse("forum_extension:create_category"), status_code=200)


def test_display_banners(client, db):
forum = CategoryForumFactory(with_child=True, with_public_perms=True)
ForumFactory(parent=forum, with_public_perms=True, with_image=True)
url = reverse("forum_extension:forum", kwargs={"pk": forum.pk, "slug": forum.slug})
response = client.get(url)
for child in forum.get_children():
assertContains(response, child.image.url.split("=")[0])
3 changes: 2 additions & 1 deletion lacommunaute/templates/forum/forum_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ <h3 class="h3 mb-0">
<p class="h3 lh-base">
<i class="ri-newspaper-line font-weight-normal"></i> {{ node.obj.name }}
</p>
{% if node.obj.short_description %}<div>{{ node.obj.short_description }}</div>{% endif %}
<div>{% include "forum/partials/forum_banner.html" with forum=node.obj only %}</div>
{% if node.obj.short_description %}<div class="mt-3">{{ node.obj.short_description }}</div>{% endif %}
</div>
<div class="card-footer text-end">
<a href="{% url 'forum_extension:forum' node.obj.slug node.obj.id %}"
Expand Down

0 comments on commit 4b68827

Please sign in to comment.