forked from hotwire-django/hotwire-django-realworld
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hotwire-django#8 - Allow users to favorite articles
- Loading branch information
1 parent
852411b
commit 7a953b9
Showing
4 changed files
with
75 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<turbo-frame id="favorite-button-{{ article.slug }}"> | ||
{% if request.user.is_authenticated %} | ||
<form method="POST" action="{% url 'article_favorite' article.slug %}" class="list-inline-item"> | ||
{% csrf_token %} | ||
|
||
{% if has_favorited %} | ||
<button class="btn btn-sm btn-primary"> | ||
<i class="ion-heart"></i> | ||
Unfavorite Post <span class="counter">({{ article.favorited_by__count }})</span> | ||
</button> | ||
{% else %} | ||
<button class="btn btn-sm btn-outline-primary"> | ||
<i class="ion-heart"></i> | ||
Favorite Post <span class="counter">({{ article.favorited_by__count }})</span> | ||
</button> | ||
{% endif %} | ||
</form> | ||
{% else %} | ||
<a data-turbo="false" href="{% url 'login' %}" class="btn btn-sm btn-outline-primary"> | ||
<i class="ion-heart"></i> | ||
Login to Favorite <span class="counter">({{ article.favorited_by__count }})</span> | ||
</a> | ||
{% endif %} | ||
</turbo-frame> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters