mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-23 07:13:52 -05:00
Add blocking and muting
This commit is contained in:
parent
d0bed792b2
commit
4d31412e75
58
brutaldon/templates/main/block.html
Normal file
58
brutaldon/templates/main/block.html
Normal file
@ -0,0 +1,58 @@
|
||||
{% extends "base.html" %}
|
||||
{% load taglinks %}
|
||||
{% load sanitizer %}
|
||||
|
||||
{% block title %}Brutaldon - confirm (un)block {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if relationship.blocking %}
|
||||
<h1 class="title">Unblock this user?</h1>
|
||||
{% else %}
|
||||
<h1 class="title">Block 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 'block' 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="block"
|
||||
value="Confirm">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
58
brutaldon/templates/main/mute.html
Normal file
58
brutaldon/templates/main/mute.html
Normal file
@ -0,0 +1,58 @@
|
||||
{% extends "base.html" %}
|
||||
{% load taglinks %}
|
||||
{% load sanitizer %}
|
||||
|
||||
{% block title %}Brutaldon - confirm (un)mute {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% if relationship.muting %}
|
||||
<h1 class="title">Unmute this user?</h1>
|
||||
{% else %}
|
||||
<h1 class="title">Mute 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 'mute' 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="mute"
|
||||
value="Confirm">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
{% endblock %}
|
@ -4,7 +4,7 @@
|
||||
{% load taglinks %}
|
||||
|
||||
{% block title %}
|
||||
Brutaldon - {{ timeline }} timelime
|
||||
Brutaldon - {{ user.acct }} timelime
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
@ -33,6 +33,7 @@ Brutaldon - {{ timeline }} timelime
|
||||
<div class="content">
|
||||
{{ user.note | relink_toot | strip_html | safe }}
|
||||
</div>
|
||||
{% if user.acct != own_username %}
|
||||
<div class="level">
|
||||
<div class="level-left">
|
||||
{% if relationship.requested %}
|
||||
@ -85,6 +86,7 @@ Brutaldon - {{ timeline }} timelime
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -48,7 +48,7 @@ urlpatterns = [
|
||||
path('delete/<int:id>', views.delete, name='delete'),
|
||||
path('follow/<int:id>', views.follow, name='follow'),
|
||||
path('block/<int:id>', views.block, name='block'),
|
||||
path('mute/<int:id>', views.follow, name='mute'),
|
||||
path('mute/<int:id>', views.mute, name='mute'),
|
||||
path('search', views.search, name='search'),
|
||||
path('search_results', views.search_results, name='search_results'),
|
||||
path('', views.home),
|
||||
|
@ -443,16 +443,53 @@ def follow(request, id):
|
||||
return redirect(user, user_dict.acct)
|
||||
else:
|
||||
return render(request, 'main/follow.html',
|
||||
{"user": user_dict, "relationship": relationship, "confirm_page": True,
|
||||
{"user": user_dict, "relationship": relationship,
|
||||
"confirm_page": True,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
|
||||
@never_cache
|
||||
def block(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.blocking:
|
||||
mastodon.account_unblock(id)
|
||||
else:
|
||||
mastodon.account_block(id)
|
||||
return redirect(user, user_dict.acct)
|
||||
else:
|
||||
return render(request, 'main/block.html',
|
||||
{"user": user_dict, "relationship": relationship,
|
||||
"confirm_page": True,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
|
||||
|
||||
@never_cache
|
||||
def mute(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.muting:
|
||||
mastodon.account_unmute(id)
|
||||
else:
|
||||
mastodon.account_mute(id)
|
||||
return redirect(user, user_dict.acct)
|
||||
else:
|
||||
return render(request, 'main/mute.html',
|
||||
{"user": user_dict, "relationship": relationship,
|
||||
"confirm_page": True,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
|
||||
|
||||
def search(request):
|
||||
return render(request, 'main/search.html',
|
||||
|
Loading…
Reference in New Issue
Block a user