Implement follow/unfollow
This commit is contained in:
parent
d863de568d
commit
9122a44216
|
@ -0,0 +1,60 @@
|
|||
{% extends "base.html" %}
|
||||
{% load taglinks %}
|
||||
{% load sanitizer %}
|
||||
|
||||
{% block title %}Brutaldon - confirm (un)follow {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if relationship.requested %}
|
||||
<h1 class="title">Cancel follow request?</h1>
|
||||
{% elif relationship.following %}
|
||||
<h1 class="title">Unfollow this user?</h1>
|
||||
{% else %}
|
||||
<h1 class="title">Follow this user?</h1>
|
||||
{% endif %}
|
||||
|
||||
<article class="media user-info">
|
||||
<figure class="media-left">
|
||||
<p class="image is-64x64">
|
||||
<a href="{% url "user" user.acct %}">
|
||||
<img src="{{ user.avatar }}"
|
||||
alt="">
|
||||
</a>
|
||||
</p>
|
||||
</figure>
|
||||
<div class="media-content">
|
||||
<div class="content">
|
||||
<p>
|
||||
<strong>{{ user.display_name }}</strong>
|
||||
<small>
|
||||
<a href="{% url "user" user.acct %}">
|
||||
@{{ user.acct }}
|
||||
</a>
|
||||
</small>
|
||||
</p>
|
||||
{{ user.note | relink_toot | strip_html | safe }}
|
||||
<p>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<form method="POST" action="{% url 'follow' user.id %}">
|
||||
{% csrf_token %}
|
||||
<div class="level is-mobile">
|
||||
<div class="level-left">
|
||||
<div class="level-item">
|
||||
<input class="button" type="submit" name="cancel" value="Cancel">
|
||||
</div>
|
||||
</div>
|
||||
<div class="level-right">
|
||||
<div class="level-item">
|
||||
<input class="button is-primary" type="submit" name="follow"
|
||||
value="Confirm">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
|
@ -422,7 +422,23 @@ def delete(request, id):
|
|||
|
||||
@never_cache
|
||||
def follow(request, id):
|
||||
pass
|
||||
mastodon = get_mastodon(request)
|
||||
try:
|
||||
user_dict = mastodon.account(id)
|
||||
relationship = mastodon.account_relationships(user_dict.id)[0]
|
||||
except IndexError:
|
||||
raise Http404("The user could not be found.")
|
||||
if request.method == 'POST':
|
||||
if not request.POST.get('cancel', None):
|
||||
if relationship.requested or relationship.following:
|
||||
mastodon.account_unfollow(id)
|
||||
else:
|
||||
mastodon.account_follow(id)
|
||||
return redirect(user, user_dict.acct)
|
||||
else:
|
||||
return render(request, 'main/follow.html',
|
||||
{"user": user_dict, "relationship": relationship, "confirm_page": True,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
|
||||
@never_cache
|
||||
def block(request, id):
|
||||
|
|
Loading…
Reference in New Issue