Skip to content

Commit

Permalink
feat(poster): move forum mention
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed May 13, 2024
1 parent d182529 commit 049dda3
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# serializer version: 1
# name: TestPosterTemplate.test_topic_from_other_public_forum_in_topics_view[topic_from_other_public_forum_in_topics_view]
'''
<small class="text-muted poster-infos">
Par :


<a class="matomo-event" data-matomo-action="view" data-matomo-category="engagement" data-matomo-option="member" href="/members/profile/poster_username/">
Alan T.
</a>,


dans <a href="forum_url">Abby's Forum</a>,
il y a 0 minute

</small>
'''
# ---
# name: TestPosterTemplate.test_topic_in_its_own_public_forum[topic_in_its_own_public_forum]
'''
<small class="text-muted poster-infos">
Par :


<a class="matomo-event" data-matomo-action="view" data-matomo-category="engagement" data-matomo-option="member" href="/members/profile/poster_username/">
Dermot T.
</a>,
il y a 0 minute

</small>
'''
# ---
# name: TestPosterTemplate.test_topic_in_topics_view[topic_in_topics_view]
'''
<small class="text-muted poster-infos">
Par :


<a class="matomo-event" data-matomo-action="view" data-matomo-category="engagement" data-matomo-option="member" href="/members/profile/poster_username/">
Jeff B.
</a>,
il y a 0 minute

</small>
'''
# ---
51 changes: 51 additions & 0 deletions lacommunaute/forum_conversation/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
from lacommunaute.forum_moderation.factories import BlockedDomainNameFactory, BlockedEmailFactory
from lacommunaute.forum_upvote.factories import UpVoteFactory
from lacommunaute.users.factories import UserFactory
from lacommunaute.utils.testing import parse_response_to_soup


faker = Faker(settings.LANGUAGE_CODE)
Expand Down Expand Up @@ -834,6 +835,56 @@ def test_template_name(self):
self.assertTemplateUsed(response, "forum_conversation/topic_list.html")


class TestPosterTemplate:
def test_topic_in_topics_view(self, client, db, snapshot):
topic = TopicFactory(with_post=True, poster=UserFactory(first_name="Jeff", last_name="Buckley"))
response = client.get(reverse("forum_conversation_extension:topics"))
soup = parse_response_to_soup(
response, replace_in_href=[(topic.poster.username, "poster_username")], selector=".poster-infos"
)
assert str(soup) == snapshot(name="topic_in_topics_view")

def test_topic_from_other_public_forum_in_topics_view(self, client, db, snapshot):
# first_public_forum
ForumFactory(with_public_perms=True)

topic = TopicFactory(
with_post=True,
forum=ForumFactory(with_public_perms=True, name="Abby's Forum"),
poster=UserFactory(first_name="Alan", last_name="Turing"),
)
response = client.get(reverse("forum_conversation_extension:topics"))
soup = parse_response_to_soup(
response,
replace_in_href=[
(topic.poster.username, "poster_username"),
(
reverse("forum_extension:forum", kwargs={"slug": topic.forum.slug, "pk": topic.forum.pk}),
"forum_url",
),
],
selector=".poster-infos",
)
assert str(soup) == snapshot(name="topic_from_other_public_forum_in_topics_view")

def test_topic_in_its_own_public_forum(self, client, db, snapshot):
# first_public_forum
ForumFactory(with_public_perms=True)

topic = TopicFactory(
with_post=True,
forum=ForumFactory(with_public_perms=True, name="Joe's Forum"),
poster=UserFactory(first_name="Dermot", last_name="Turing"),
)
response = client.get(
reverse("forum_extension:forum", kwargs={"slug": topic.forum.slug, "pk": topic.forum.pk})
)
soup = parse_response_to_soup(
response, replace_in_href=[(topic.poster.username, "poster_username")], selector=".poster-infos"
)
assert str(soup) == snapshot(name="topic_in_its_own_public_forum")


class NewsFeedTopicListViewTest(TestCase):
@classmethod
def setUpTestData(cls):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{% load forum_permission_tags %}
{% get_permission 'can_edit_post' post request.user as user_can_edit_post %}
{% endif %}
<small class="text-muted">
<small class="text-muted poster-infos">
{% spaceless %}
{% with poster=post.poster_display_name %}
Par :
Expand All @@ -17,6 +17,9 @@
{% else %}
{{ poster }},
{% endif %}
{% if forum and forum != topic.forum %}
dans <a href="{% url 'forum_extension:forum' topic.forum.slug topic.forum.pk %}">{{ topic.forum }}</a>,
{% endif %}
{% endwith %}
{% endspaceless %}
{{ post.created|relativetimesince_fr }}
Expand Down
5 changes: 1 addition & 4 deletions lacommunaute/templates/forum_conversation/topic_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@
<div class="card-body pt-0">
<div class="row">
<div class="col-12 post-content-wrapper mb-1">
{% include "forum_conversation/partials/poster.html" with post=topic.first_post topic=topic is_topic_head=True %}
{% include "forum_conversation/partials/poster.html" with post=topic.first_post topic=topic is_topic_head=True forum=forum %}
</div>
<div class="col-12 post-content mb-3">
{% include "forum_conversation/partials/topic_tags.html" with tags=topic.tags.all %}
{% if forum != topic.forum %}
<a href="{% url 'forum_extension:forum' topic.forum.slug topic.forum.pk %}"><span class="badge badge-xs rounded-pill bg-info-lighter text-info text-decoration-underline">{{ topic.forum }}</span></a>
{% endif %}
</div>
<div class="col-12 post-content">
<div id="showmoretopicsarea{{ topic.pk }}">
Expand Down

0 comments on commit 049dda3

Please sign in to comment.