(Un)follow and boost/like buttons via javascript

Works on #78
This commit is contained in:
Mouse Reeve
2020-03-21 14:29:39 -07:00
parent 1ec515034c
commit e0bd8200ad
8 changed files with 49 additions and 37 deletions

View File

@ -1,10 +1,13 @@
{% if request.user == user %}
{% elif request.user in user.follower_requests.all %}
<div>
Follow request already sent.
</div>
{% elif not request.user in user.followers.all %}
<form action="/follow/" method="post">
{% else %}
<form action="/follow/" method="POST" onsubmit="interact(event)" class="follow-{{ user.id }} {% if request.user in user.followers.all %}hidden{%endif %}" data-id="follow-{{ user.id }}">
{% csrf_token %}
<input type="hidden" name="user" value="{{ user.username }}"></input>
{% if user.manually_approves_followers %}
@ -13,8 +16,7 @@ Follow request already sent.
<button type="submit">Follow</button>
{% endif %}
</form>
{% else %}
<form action="/unfollow/" method="post">
<form action="/unfollow/" method="POST" onsubmit="interact(event)" class="follow-{{ user.id }} {% if not request.user in user.followers.all %}hidden{%endif %}" data-id="follow-{{ user.id }}">
{% csrf_token %}
<input type="hidden" name="user" value="{{ user.username }}"></input>
<button type="submit">Unfollow</button>

View File

@ -12,7 +12,7 @@
</button>
</form>
<form name="boost" action="/boost/{{ activity.id }}" method="POST" onsubmit="return interact(event)" class="{% if False %}active{% endif %}">
<form name="boost" action="/boost/{{ activity.id }}" method="post" onsubmit="return interact(event)" class="boost-{{ status.id }} {% if False %}hidden{% endif %}" data-id="boost-{{ status.id }}">
{% csrf_token %}
<button type="submit">
<span class="icon icon-boost">
@ -20,8 +20,16 @@
</span>
</button>
</form>
<form name="unboost" action="/unboost/{{ activity.id }}" method="post" onsubmit="return interact(event)" class="boost-{{ status.id }} active {% if not False %}hidden{% endif %}" data-id="boost-{{ status.id }}">
{% csrf_token %}
<button type="submit">
<span class="icon icon-boost">
<span class="hidden-text">Un-boost status</span>
</span>
</button>
</form>
<form name="favorite" action="/favorite/{{ activity.id }}" method="POST" onsubmit="return interact(event)" class="{% if request.user|liked:status %}active{% endif %}">
<form name="favorite" action="/favorite/{{ activity.id }}" method="POST" onsubmit="return interact(event)" class="fav-{{ status.id }} {% if request.user|liked:status %}hidden{% endif %}" data-id="fav-{{ status.id }}">
{% csrf_token %}
<button type="submit">
<span class="icon icon-heart">
@ -29,5 +37,13 @@
</span>
</button>
</form>
<form name="favorite" action="/favorite/{{ activity.id }}" method="POST" onsubmit="return interact(event)" class="fav-{{ status.id }} active {% if not request.user|liked:status %}hidden{% endif %}" data-id="fav-{{ status.id }}">
{% csrf_token %}
<button type="submit">
<span class="icon icon-heart">
<span class="hidden-text">Un-like status</span>
</span>
</button>
</form>
</div>