1
0
mirror of https://gitlab.com/brutaldon/brutaldon synced 2024-12-28 08:41:52 +01:00

Add boosting, with same caveats as faving

This commit is contained in:
Jason McBrayer 2018-04-30 18:49:06 -04:00
parent 1b561fa90e
commit 804a4dfd67
4 changed files with 53 additions and 3 deletions

View File

@ -0,0 +1,31 @@
{% extends "base.html" %}
{% block title %} Brutaldon - confirm boost {% endblock %}
{% block content %}
{% if toot.reblogged %}
<h1 class="title">Unboost that toot?</h1>
{% else %}
<h1 class="title" >Boost that toot?</h1>
{% endif %}
<div class="box">
{% include "main/toot_partial.html" with toot=toot %}
</div>
<form method="POST" action="{% url "boost" toot.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="boost"
value="Boost">
</div>
</div>
</div>
</form>
{% endblock %}

View File

@ -68,10 +68,16 @@
<span class="is-invisible">Reply</span>
</i></span>
</a>
<a class="level-item">
<span class="icon is-small"><i class="fa fa-retweet">
<a class="level-item" href="{% url "boost" toot.id %}">
<span class="icon is-small">
{% if toot.reblogged %}
<i class="fa fa-retweet has-text-warning">
{% else %}
<i class="fa fa-retweet" >
{% endif %}
<span class="is-invisible" >Boost</span>
</i></span>
</i>
</span>
</a>
<a class="level-item" href="{% url "fav" toot.id %}">
<span class="icon is-small">

View File

@ -31,5 +31,6 @@ urlpatterns = [
path('toot', views.toot, name="toot"),
path('reply/<int:id>', views.reply, name='reply'),
path('fav/<int:id>', views.fav, name='fav'),
path('boost/<int:id>', views.boost, name='boost'),
path('', views.home),
]

View File

@ -206,3 +206,15 @@ def fav(request, id):
return redirect(thread, id)
else:
return render(request, 'main/fav.html', {"toot": toot})
def boost(request, id):
mastodon = get_mastodon(request)
toot = mastodon.status(id)
if request.method == 'POST':
if toot.reblogged:
mastodon.status_unreblog(id)
else:
mastodon.status_reblog(id)
return redirect(thread, id)
else:
return render(request, 'main/boost.html', {"toot": toot})