diff --git a/bookwyrm/incoming.py b/bookwyrm/incoming.py index ad44fd97f..bcb021ca7 100644 --- a/bookwyrm/incoming.py +++ b/bookwyrm/incoming.py @@ -299,7 +299,7 @@ def handle_unboost(activity): remote_id=activity['object']['id'] ).first() if boost: - status_builder.delete_status(boost) + boost.delete() @app.task diff --git a/bookwyrm/outgoing.py b/bookwyrm/outgoing.py index 7a21048b6..c0253a99a 100644 --- a/bookwyrm/outgoing.py +++ b/bookwyrm/outgoing.py @@ -320,6 +320,17 @@ def handle_boost(user, status): broadcast(user, boost_activity) +def handle_unboost(user, status): + ''' a user regrets boosting a status ''' + boost = models.Boost.objects.filter( + boosted_status=status, user=user + ).first() + activity = boost.to_undo_activity(user) + + boost.delete() + broadcast(user, activity) + + def handle_update_book(user, book): ''' broadcast the news about our book ''' broadcast(user, book.to_update_activity(user)) diff --git a/bookwyrm/templates/snippets/boost_button.html b/bookwyrm/templates/snippets/boost_button.html index 2c747fe25..57765bed1 100644 --- a/bookwyrm/templates/snippets/boost_button.html +++ b/bookwyrm/templates/snippets/boost_button.html @@ -1,6 +1,6 @@ {% load fr_display %} -{% with activity.id|uuid as uuid %} -
+{% with status.id|uuid as uuid %} + {% csrf_token %}
-
+ {% csrf_token %}
-
+ {% csrf_token %} -
- - {% endif %} - - - - -{% else %} -
-
-

+ {% if status.status_type == 'Boost' %} {% include 'snippets/avatar.html' with user=status.user %} {% include 'snippets/username.html' with user=status.user %} - deleted this status -

-
-
+ boosted + {% include 'snippets/status_body.html' with status=status|boosted_status %} + {% else %} + {% include 'snippets/status_body.html' with status=status %} + {% endif %} {% endif %} diff --git a/bookwyrm/templates/snippets/status_body.html b/bookwyrm/templates/snippets/status_body.html new file mode 100644 index 000000000..9eec95cde --- /dev/null +++ b/bookwyrm/templates/snippets/status_body.html @@ -0,0 +1,120 @@ +{% load fr_display %} +{% load humanize %} + +{% if not status.deleted %} +
+
+
+
+
+ {% include 'snippets/status_header.html' with status=status %} +
+
+
+
+ +
+ {% include 'snippets/status_content.html' with status=status %} +
+ + +
+{% else %} +
+
+

+ {% include 'snippets/avatar.html' with user=status.user %} + {% include 'snippets/username.html' with user=status.user %} + deleted this status +

+
+
+{% endif %} diff --git a/bookwyrm/urls.py b/bookwyrm/urls.py index f761eac91..6399c87e2 100644 --- a/bookwyrm/urls.py +++ b/bookwyrm/urls.py @@ -116,6 +116,7 @@ urlpatterns = [ re_path(r'^favorite/(?P\d+)/?$', actions.favorite), re_path(r'^unfavorite/(?P\d+)/?$', actions.unfavorite), re_path(r'^boost/(?P\d+)/?$', actions.boost), + re_path(r'^unboost/(?P\d+)/?$', actions.unboost), re_path(r'^delete-status/?$', actions.delete_status), diff --git a/bookwyrm/view_actions.py b/bookwyrm/view_actions.py index 653a9c23a..d938674de 100644 --- a/bookwyrm/view_actions.py +++ b/bookwyrm/view_actions.py @@ -508,6 +508,7 @@ def unfavorite(request, status_id): outgoing.handle_unfavorite(request.user, status) return redirect(request.headers.get('Referer', '/')) + @login_required def boost(request, status_id): ''' boost a status ''' @@ -516,6 +517,14 @@ def boost(request, status_id): return redirect(request.headers.get('Referer', '/')) +@login_required +def unboost(request, status_id): + ''' boost a status ''' + status = models.Status.objects.get(id=status_id) + outgoing.handle_unboost(request.user, status) + return redirect(request.headers.get('Referer', '/')) + + @login_required def delete_status(request): ''' delete and tombstone a status '''