Skip to content

Commit

Permalink
update upvote icon
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentporte committed Dec 3, 2024
1 parent e248848 commit 9dd65fd
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 32 deletions.
40 changes: 20 additions & 20 deletions lacommunaute/forum/tests/__snapshots__/tests_views.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,8 @@
<div class="d-inline-block" id="upvotesarea10000">


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


Expand Down Expand Up @@ -486,8 +486,8 @@
<div class="d-inline-block" id="upvotesarea10000">


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


Expand All @@ -499,8 +499,8 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>0</span>
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour vous abonner à ce contenu">
<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 @@ -528,8 +528,8 @@
<div class="d-inline-block" id="upvotesarea10000">


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


Expand All @@ -541,8 +541,8 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>1</span>
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour vous abonner à ce contenu">
<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 @@ -570,8 +570,8 @@
<div class="d-inline-block" id="upvotesarea10000">


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


Expand All @@ -583,8 +583,8 @@
<div class="d-inline-block" id="upvotesarea10000">


<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour sauvegarder">
<i aria-hidden="true" class="ri-bookmark-line me-1"></i><span>2</span>
<a class="btn btn-sm btn-ico btn-link btn-secondary px-2" data-bs-placement="top" data-bs-toggle="tooltip" href="/pro_connect/authorize?next=%2Fforum%2Ftest-forum-forum-[PK of Forum]%2F%23[PK of Forum]" rel="nofollow" title="Connectez-vous pour vous abonner à ce contenu">
<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
6 changes: 3 additions & 3 deletions lacommunaute/templates/partials/upvotes.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
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 %}
Expand All @@ -18,8 +18,8 @@
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>
title="Connectez-vous pour vous abonner à ce contenu">
<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

0 comments on commit 9dd65fd

Please sign in to comment.