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">
|
<div class="level-left">
|
||||||
{% if relationship.requested %}
|
{% if relationship.requested %}
|
||||||
<a class="level-item fa fa-hourglass" title="cancel request"
|
<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>
|
<span class="is-hidden">Cancel request</span>
|
||||||
</a>
|
</a>
|
||||||
{% elif not relationship.following %}
|
{% elif not relationship.following %}
|
||||||
<a class="level-item fa fa-user-plus" title="follow"
|
<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>
|
<span class="is-hidden">Follow</span>
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="level-item fa fa-user-times" title="unfollow"
|
<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>
|
<span class="is-hidden">Unfollow</span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -60,27 +66,36 @@ Brutaldon ({{ own_acct.username }}) - {{ user.acct }} timelime
|
|||||||
href="{% url 'toot' user.acct %}" title="mention">
|
href="{% url 'toot' user.acct %}" title="mention">
|
||||||
<span class="is-hidden">Mention</span>
|
<span class="is-hidden">Mention</span>
|
||||||
</a>
|
</a>
|
||||||
|
<i id="user-spinner" class="fa fa-spinner fa-spin" style="display:none"></i>
|
||||||
</div>
|
</div>
|
||||||
<div class="level-right">
|
<div class="level-right">
|
||||||
{% if not relationship.muting %}
|
{% if not relationship.muting %}
|
||||||
<a class="level-item fa fa-volume-off" title="mute"
|
<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>
|
<span class="is-hidden">Mute</span>
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="level-item fa fa-volume-up" title="unmute"
|
<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>
|
<span class="is-hidden">Unmute</span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not relationship.blocking %}
|
{% if not relationship.blocking %}
|
||||||
<a class="level-item fa fa-ban" title="block"
|
<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>
|
<span class="is-hidden">Block</span>
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a class="level-item fa fa-circle-o" title="unblock"
|
<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>
|
<span class="is-hidden">Unblock</span>
|
||||||
</a>
|
</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -11,6 +11,7 @@ from mastodon import Mastodon, AttribAccessDict, MastodonError
|
|||||||
from urllib import parse
|
from urllib import parse
|
||||||
from pdb import set_trace
|
from pdb import set_trace
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
class NotLoggedInException(Exception):
|
class NotLoggedInException(Exception):
|
||||||
pass
|
pass
|
||||||
@ -620,6 +621,14 @@ def follow(request, id):
|
|||||||
mastodon.account_unfollow(id)
|
mastodon.account_unfollow(id)
|
||||||
else:
|
else:
|
||||||
mastodon.account_follow(id)
|
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)
|
return redirect(user, user_dict.acct)
|
||||||
else:
|
else:
|
||||||
return render(request, 'main/follow.html',
|
return render(request, 'main/follow.html',
|
||||||
|
Loading…
Reference in New Issue
Block a user