Skip to content

Commit

Permalink
feat: renommage des upvotes (#842)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte authored Dec 4, 2024
1 parent 09397af commit 4491d8d
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 38 deletions.
26 changes: 13 additions & 13 deletions lacommunaute/forum/tests/__snapshots__/tests_views.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-10000%2F%2310000" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>0</span>
<i aria-hidden="true" class="ri-notification-2-line me-1"></i><span>0</span>
</a>


Expand Down Expand Up @@ -487,7 +487,7 @@


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>0</span>
<i aria-hidden="true" class="ri-notification-2-line me-1"></i><span>0</span>
</a>


Expand All @@ -500,7 +500,7 @@


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>0</span>
<i aria-hidden="true" class="ri-notification-2-line me-1"></i><span>0</span>
</a>


Expand All @@ -514,8 +514,8 @@

<form hx-post="/upvote/forum/" hx-swap="outerHTML" hx-target="#upvotesarea10000" id="upvote-button10000">
<input name="pk" type="hidden" value="10000"/>
<button class="btn btn-sm btn-ico btn-secondary matomo-event px-2" data-matomo-action="upvote" data-matomo-category="engagement" data-matomo-option="post" title="Sauvegarder" type="submit">
<i aria-hidden="true" class="ri-bookmark-fill me-1"></i><span>1</span>
<button class="btn btn-sm btn-ico btn-secondary matomo-event px-2" data-matomo-action="upvote" data-matomo-category="engagement" data-matomo-option="post" title="S'abonner" type="submit">
<i aria-hidden="true" class="ri-notification-2-fill me-1"></i><span>1</span>
</button>
</form>

Expand All @@ -529,7 +529,7 @@


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>1</span>
<i aria-hidden="true" class="ri-notification-2-line me-1"></i><span>1</span>
</a>


Expand All @@ -542,7 +542,7 @@


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>1</span>
<i aria-hidden="true" class="ri-notification-2-line me-1"></i><span>1</span>
</a>


Expand All @@ -556,8 +556,8 @@

<form hx-post="/upvote/forum/" hx-swap="outerHTML" hx-target="#upvotesarea10000" id="upvote-button10000">
<input name="pk" type="hidden" value="10000"/>
<button class="btn btn-sm btn-ico btn-secondary matomo-event px-2" data-matomo-action="upvote" data-matomo-category="engagement" data-matomo-option="post" title="Sauvegarder" type="submit">
<i aria-hidden="true" class="ri-bookmark-fill me-1"></i><span>2</span>
<button class="btn btn-sm btn-ico btn-secondary matomo-event px-2" data-matomo-action="upvote" data-matomo-category="engagement" data-matomo-option="post" title="S'abonner" type="submit">
<i aria-hidden="true" class="ri-notification-2-fill me-1"></i><span>2</span>
</button>
</form>

Expand All @@ -571,7 +571,7 @@


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>2</span>
<i aria-hidden="true" class="ri-notification-2-line me-1"></i><span>2</span>
</a>


Expand All @@ -584,7 +584,7 @@


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/users/login/?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>2</span>
<i aria-hidden="true" class="ri-notification-2-line me-1"></i><span>2</span>
</a>


Expand All @@ -598,8 +598,8 @@

<form hx-post="/upvote/forum/" hx-swap="outerHTML" hx-target="#upvotesarea10000" id="upvote-button10000">
<input name="pk" type="hidden" value="10000"/>
<button class="btn btn-sm btn-ico btn-secondary matomo-event px-2" data-matomo-action="upvote" data-matomo-category="engagement" data-matomo-option="post" title="Sauvegarder" type="submit">
<i aria-hidden="true" class="ri-bookmark-fill me-1"></i><span>3</span>
<button class="btn btn-sm btn-ico btn-secondary matomo-event px-2" data-matomo-action="upvote" data-matomo-category="engagement" data-matomo-option="post" title="S'abonner" type="submit">
<i aria-hidden="true" class="ri-notification-2-fill me-1"></i><span>3</span>
</button>
</form>

Expand Down
4 changes: 2 additions & 2 deletions lacommunaute/forum_conversation/tests/tests_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ def test_post_has_no_upvote(self):

response = self.client.get(self.url)
self.assertContains(
response, '<i class="ri-bookmark-line me-1" aria-hidden="true"></i><span>0</span>', status_code=200
response, '<i class="ri-notification-2-line me-1" aria-hidden="true"></i><span>0</span>', status_code=200
)

def test_post_has_upvote_by_user(self):
Expand All @@ -673,7 +673,7 @@ def test_post_has_upvote_by_user(self):

response = self.client.get(self.url)
self.assertContains(
response, '<i class="ri-bookmark-fill me-1" aria-hidden="true"></i><span>1</span>', status_code=200
response, '<i class="ri-notification-2-fill me-1" aria-hidden="true"></i><span>1</span>', status_code=200
)

def test_certified_post_is_highlighted(self):
Expand Down
6 changes: 3 additions & 3 deletions lacommunaute/forum_conversation/tests/tests_views_htmx.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,15 @@ def test_upvote_annotations(self):

response = view.get(request)
self.assertContains(
response, '<i class="ri-bookmark-line me-1" aria-hidden="true"></i><span>0</span>', status_code=200
response, '<i class="ri-notification-2-line me-1" aria-hidden="true"></i><span>0</span>', status_code=200
)

UpVoteFactory(content_object=post, voter=UserFactory())
UpVoteFactory(content_object=post, voter=self.user)

response = view.get(request)
self.assertContains(
response, '<i class="ri-bookmark-fill me-1" aria-hidden="true"></i><span>2</span>', status_code=200
response, '<i class="ri-notification-2-fill me-1" aria-hidden="true"></i><span>2</span>', status_code=200
)

def test_certified_post_highlight(self):
Expand Down Expand Up @@ -287,7 +287,7 @@ def test_create_post_as_authenticated_user(self, *args):
self.assertContains(response, self.content, status_code=200)
self.assertIsInstance(response.context["form"], PostForm)
self.assertEqual(1, ForumReadTrack.objects.count())
self.assertContains(response, '<i class="ri-bookmark-line me-1" aria-hidden="true"></i><span>0</span>')
self.assertContains(response, '<i class="ri-notification-2-line me-1" aria-hidden="true"></i><span>0</span>')
self.topic.refresh_from_db()
self.assertEqual(self.topic.posts.count(), 2)
self.assertEqual(
Expand Down
8 changes: 6 additions & 2 deletions lacommunaute/forum_upvote/tests/test_forumupvoteview.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ def test_upvote_downvote_with_permission(client, db):

# upvote
response = client.post(url, data=form_data)
assertContains(response, '<i class="ri-bookmark-fill me-1" aria-hidden="true"></i><span>1</span>', status_code=200)
assertContains(
response, '<i class="ri-notification-2-fill me-1" aria-hidden="true"></i><span>1</span>', status_code=200
)
assert UpVote.objects.get()

# downvote
response = client.post(url, data=form_data)
assertContains(response, '<i class="ri-bookmark-line me-1" aria-hidden="true"></i><span>0</span>', status_code=200)
assertContains(
response, '<i class="ri-notification-2-line me-1" aria-hidden="true"></i><span>0</span>', status_code=200
)
assert not UpVote.objects.all()


Expand Down
8 changes: 6 additions & 2 deletions lacommunaute/forum_upvote/tests/test_postupvoteview.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ def test_upvote_with_permission(client, db):

# upvote
response = client.post(url, data=form_data)
assertContains(response, '<i class="ri-bookmark-fill me-1" aria-hidden="true"></i><span>1</span>', status_code=200)
assertContains(
response, '<i class="ri-notification-2-fill me-1" aria-hidden="true"></i><span>1</span>', status_code=200
)
assert UpVote.objects.get(
voter_id=user.id,
object_id=topic.first_post.id,
Expand All @@ -43,7 +45,9 @@ def test_upvote_with_permission(client, db):

# downvote
response = client.post(url, data=form_data)
assertContains(response, '<i class="ri-bookmark-line me-1" aria-hidden="true"></i><span>0</span>', status_code=200)
assertContains(
response, '<i class="ri-notification-2-line me-1" aria-hidden="true"></i><span>0</span>', status_code=200
)
assert not UpVote.objects.all()


Expand Down
18 changes: 6 additions & 12 deletions lacommunaute/templates/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,13 @@
<div class="dropdown-divider"></div>
</li>
<li>
<a href="{% url 'members:profile' user.username %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="member">Accéder à mon profil</a>
<a href="{% url 'members:profile' user.username %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="member">{% trans "Go to my profile" %}</a>
</li>
<li>
<a href="{% url 'forum_upvote:mine' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="upvotes">Accéder à mes sauvegardes</a>
<a href="{% url 'forum_upvote:mine' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="upvotes">{% trans "Go to my UpVotes" %}</a>
</li>
<li>
<a href="{% url 'event:myevents' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="event">Accéder à mes évènements</a>
</li>
<li>
<a href="{% url 'forum_extension:index' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="forums">Accéder à mes thématiques</a>
<a href="{% url 'event:myevents' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="event">{% trans "Go to my events" %}</a>
</li>
{% if user.is_superuser %}
<li>
Expand Down Expand Up @@ -239,16 +236,13 @@ <h4 class="h5 mb-0 btn-ico align-items-center" id="offcanvasApplyFiltersLabel">
<div class="dropdown-divider"></div>
</li>
<li>
<a href="{% url 'members:profile' user.username %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="member">Accéder à mon profil</a>
</li>
<li>
<a href="{% url 'forum_upvote:mine' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="upvotes">Accéder à mes sauvegardes</a>
<a href="{% url 'members:profile' user.username %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="member">{% trans "Go to my profile" %}</a>
</li>
<li>
<a href="{% url 'event:myevents' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="event">Accéder à mes évènements</a>
<a href="{% url 'forum_upvote:mine' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="upvotes">{% trans "Go to my UpVotes" %}</a>
</li>
<li>
<a href="{% url 'forum_extension:index' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="forums">Accéder à mes thématiques</a>
<a href="{% url 'event:myevents' %}" class="dropdown-item text-primary matomo-event" data-matomo-category="engagement" data-matomo-action="view" data-matomo-option="event">{% trans "Go to my events" %}</a>
</li>
{% if user.is_superuser %}
<li>
Expand Down
4 changes: 2 additions & 2 deletions lacommunaute/templates/partials/upvotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
hx-swap="outerHTML">
<input type='hidden' name='pk' value="{{ obj.pk }}" />
<button type="submit" title="{% trans "UpVotes" %}" class="btn btn-sm btn-ico btn-secondary matomo-event px-2" data-matomo-category="engagement" data-matomo-action="upvote" data-matomo-option="post">
<i class="{% if obj.has_upvoted %}ri-bookmark-fill{% else %}ri-bookmark-line{% endif %} me-1" aria-hidden="true"></i><span>{{ counter }}</span>
<i class="{% if obj.has_upvoted %}ri-notification-2-fill{% else %}ri-notification-2-line{% endif %} me-1" aria-hidden="true"></i><span>{{ counter }}</span>
</button>
</form>
{% else %}
<a href="{% login_url next_url obj.id %}" class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-toggle="tooltip" data-bs-placement="top" title="Connectez-vous pour sauvegarder">
<i class="{% if obj.has_upvoted %}ri-bookmark-fill{% else %}ri-bookmark-line{% endif %} me-1" aria-hidden="true"></i><span>{{ counter }}</span>
<i class="{% if obj.has_upvoted %}ri-notification-2-fill{% else %}ri-notification-2-line{% endif %} me-1" aria-hidden="true"></i><span>{{ counter }}</span>
</a>
{% endif %}
{% endwith %}
Expand Down
13 changes: 11 additions & 2 deletions locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -914,10 +914,13 @@ msgid "Topics Engagement"
msgstr "Engagement par sujet"

msgid "UpVotes"
msgstr "Sauvegarder"
msgstr "S'abonner"

msgid "My UpVotes"
msgstr "Mes sauvegardes"
msgstr "Mes abonnements"

msgid "Go to my UpVotes"
msgstr "Voir mes abonnements"

msgid "Likes"
msgstr "Ce sujet m'intéresse"
Expand Down Expand Up @@ -1036,3 +1039,9 @@ msgstr "Partenaire"

msgid "Partners"
msgstr "Nos partenaires"

msgid "Go to my profile"
msgstr "Voir mon profil"

msgid "Go to my events"
msgstr "Voir mes évènements"

0 comments on commit 4491d8d

Please sign in to comment.