mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-12-04 14:46:24 -05:00
AJAX the follow button
This commit is contained in:
parent
3480c70a5e
commit
bd663e7539
22
brutaldon/templates/intercooler/follow.html
Normal file
22
brutaldon/templates/intercooler/follow.html
Normal file
@ -0,0 +1,22 @@
|
||||
{% if relationship.requested %}
|
||||
<a class="level-item fa fa-hourglass" title="cancel request"
|
||||
href="{% url 'follow' user.id %}"
|
||||
ic-post-to="{% url 'follow' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Cancel request</span>
|
||||
</a>
|
||||
{% elif not relationship.following %}
|
||||
<a class="level-item fa fa-user-plus" title="follow"
|
||||
href="{% url 'follow' user.id %}"
|
||||
ic-post-to="{% url 'follow' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Follow</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="level-item fa fa-user-times" title="unfollow"
|
||||
href="{% url 'follow' user.id %}"
|
||||
ic-post-to="{% url 'follow' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Unfollow</span>
|
||||
</a>
|
||||
{% endif %}
|
@ -38,17 +38,23 @@ Brutaldon ({{ own_acct.username }}) - {{ user.acct }} timelime
|
||||
<div class="level-left">
|
||||
{% if relationship.requested %}
|
||||
<a class="level-item fa fa-hourglass" title="cancel request"
|
||||
href="{% url 'follow' user.id %}">
|
||||
href="{% url 'follow' user.id %}"
|
||||
ic-post-to="{% url 'follow' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Cancel request</span>
|
||||
</a>
|
||||
{% elif not relationship.following %}
|
||||
<a class="level-item fa fa-user-plus" title="follow"
|
||||
href="{% url 'follow' user.id %}">
|
||||
href="{% url 'follow' user.id %}"
|
||||
ic-post-to="{% url 'follow' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Follow</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="level-item fa fa-user-times" title="unfollow"
|
||||
href="{% url 'follow' user.id %}">
|
||||
href="{% url 'follow' user.id %}"
|
||||
ic-post-to="{% url 'follow' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Unfollow</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
@ -60,27 +66,36 @@ Brutaldon ({{ own_acct.username }}) - {{ user.acct }} timelime
|
||||
href="{% url 'toot' user.acct %}" title="mention">
|
||||
<span class="is-hidden">Mention</span>
|
||||
</a>
|
||||
<i id="user-spinner" class="fa fa-spinner fa-spin" style="display:none"></i>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
{% if not relationship.muting %}
|
||||
<a class="level-item fa fa-volume-off" title="mute"
|
||||
href="{% url 'mute' user.id %}">
|
||||
href="{% url 'mute' user.id %}"
|
||||
ic-post-to="{% url 'mute' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Mute</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="level-item fa fa-volume-up" title="unmute"
|
||||
href="{% url 'mute' user.id %}">
|
||||
href="{% url 'mute' user.id %}"
|
||||
ic-post-to="{% url 'mute' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Unmute</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
{% if not relationship.blocking %}
|
||||
<a class="level-item fa fa-ban" title="block"
|
||||
href="{% url 'block' user.id %}">
|
||||
href="{% url 'block' user.id %}"
|
||||
ic-post-to="{% url 'block' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Block</span>
|
||||
</a>
|
||||
{% else %}
|
||||
<a class="level-item fa fa-circle-o" title="unblock"
|
||||
href="{% url 'block' user.id %}">
|
||||
href="{% url 'block' user.id %}"
|
||||
ic-post-to="{% url 'block' user.id %}"
|
||||
ic-indicator="#user-spinner" ic-replace-target="true">
|
||||
<span class="is-hidden">Unblock</span>
|
||||
</a>
|
||||
{% endif %}
|
||||
|
@ -11,6 +11,7 @@ from mastodon import Mastodon, AttribAccessDict, MastodonError
|
||||
from urllib import parse
|
||||
from pdb import set_trace
|
||||
from bs4 import BeautifulSoup
|
||||
from time import sleep
|
||||
|
||||
class NotLoggedInException(Exception):
|
||||
pass
|
||||
@ -620,6 +621,14 @@ def follow(request, id):
|
||||
mastodon.account_unfollow(id)
|
||||
else:
|
||||
mastodon.account_follow(id)
|
||||
if request.POST.get('ic-request'):
|
||||
sleep(1) # This is annoying, but the next call will return Requested instead of Following in some cases
|
||||
relationship = mastodon.account_relationships(user_dict.id)[0]
|
||||
return render(request, 'intercooler/follow.html',
|
||||
{"user": user_dict, "relationship": relationship,
|
||||
'own_acct': request.session['user'],
|
||||
'preferences': account.preferences})
|
||||
else:
|
||||
return redirect(user, user_dict.acct)
|
||||
else:
|
||||
return render(request, 'main/follow.html',
|
||||
|
Loading…
Reference in New Issue
Block a user