Skip to content

Commit

Permalink
(forum_conversation) make tags clickable
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed May 21, 2024
1 parent 29d8cd5 commit fd0d832
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions lacommunaute/forum_conversation/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,20 @@ def test_template_name(self):
response = self.client.get(self.url, **{"HTTP_HX_REQUEST": "true"})
self.assertTemplateUsed(response, "forum_conversation/topic_list.html")

def test_clickable_tags(self):
tag = Tag.objects.create(name="tag")
TopicFactory(with_post=True, forum=self.forum, with_tags=[tag.name])
self.client.force_login(self.user)

response = self.client.get(self.url)
self.assertContains(
response,
(
f'<a href="{self.url}?tags={tag.slug}"><span class="badge badge-xs rounded-pill bg-info-lighter '
f'text-info">{ tag.name }</span></a>'
),
)


class TestPosterTemplate:
def test_topic_in_topics_view(self, client, db, snapshot):
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
{% for tag in tags %}<span class="badge badge-xs rounded-pill bg-info-lighter text-info">{{ tag }}</span>{% endfor %}
{% load url_add_query %}
{% for tag in tags %}
<a href="{% url_add_query request.get_full_path tags=tag.slug %}"><span class="badge badge-xs rounded-pill bg-info-lighter text-info">{{ tag }}</span></a>
{% endfor %}

0 comments on commit fd0d832

Please sign in to comment.