Correctly cancel out of (un)boosting or faving toots

This commit is contained in:
Jason McBrayer 2018-04-30 18:53:11 -04:00
parent 804a4dfd67
commit 421d27ef07
1 changed files with 10 additions and 8 deletions

View File

@ -199,10 +199,11 @@ def fav(request, id):
mastodon = get_mastodon(request) mastodon = get_mastodon(request)
toot = mastodon.status(id) toot = mastodon.status(id)
if request.method == 'POST': if request.method == 'POST':
if toot.favourited: if not request.POST['cancel']:
mastodon.status_unfavourite(id) if toot.favourited:
else: mastodon.status_unfavourite(id)
mastodon.status_favourite(id) else:
mastodon.status_favourite(id)
return redirect(thread, id) return redirect(thread, id)
else: else:
return render(request, 'main/fav.html', {"toot": toot}) return render(request, 'main/fav.html', {"toot": toot})
@ -211,10 +212,11 @@ def boost(request, id):
mastodon = get_mastodon(request) mastodon = get_mastodon(request)
toot = mastodon.status(id) toot = mastodon.status(id)
if request.method == 'POST': if request.method == 'POST':
if toot.reblogged: if not request.POST['cancel']:
mastodon.status_unreblog(id) if toot.reblogged:
else: mastodon.status_unreblog(id)
mastodon.status_reblog(id) else:
mastodon.status_reblog(id)
return redirect(thread, id) return redirect(thread, id)
else: else:
return render(request, 'main/boost.html', {"toot": toot}) return render(request, 'main/boost.html', {"toot": toot})