From 730c49a2b6d0358c5c42849572eeaf6d43435f1a Mon Sep 17 00:00:00 2001 From: Adam Kelly Date: Sat, 22 Feb 2020 18:00:43 +0000 Subject: [PATCH] Always pass follow/unfollow parameter using POST. Fixes buttons in followers list. --- fedireads/templates/user.html | 10 ++++++---- fedireads/urls.py | 4 ++-- fedireads/views.py | 6 ++++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/fedireads/templates/user.html b/fedireads/templates/user.html index 9f095e462..c58ae2539 100644 --- a/fedireads/templates/user.html +++ b/fedireads/templates/user.html @@ -12,13 +12,15 @@ {% endif %} {% if not is_self %} {% if not request.user in user.followers.all %} -
+ {% csrf_token %} +
{% else %} -
+ {% csrf_token %} +
{% endif %} @@ -38,13 +40,13 @@ {% if not request.user in follower.followers.all %}
{% csrf_token %} - +
{% else %}
{% csrf_token %} - +
{% endif %} diff --git a/fedireads/urls.py b/fedireads/urls.py index d01b62a40..b064137ed 100644 --- a/fedireads/urls.py +++ b/fedireads/urls.py @@ -57,8 +57,8 @@ urlpatterns = [ re_path(r'^comment/?$', views.comment), re_path(r'^favorite/(?P\d+)/?$', views.favorite), re_path(r'^shelve/?$', views.shelve), - re_path(r'^follow/(?P[\w@\.-]+)/?$', views.follow), - re_path(r'^unfollow/(?P[\w@\.-]+)/?$', views.unfollow), + re_path(r'^follow/?$', views.follow), + re_path(r'^unfollow/?$', views.unfollow), re_path(r'^search/?$', views.search), re_path(r'^edit_profile/?$', views.edit_profile), diff --git a/fedireads/views.py b/fedireads/views.py index 4aa128cf7..90401e757 100644 --- a/fedireads/views.py +++ b/fedireads/views.py @@ -362,8 +362,9 @@ def favorite(request, status_id): @login_required -def follow(request, username): +def follow(request): ''' follow another user, here or abroad ''' + username = request.POST['user'] # should this be an actor rather than an id? idk to_follow = models.User.objects.get(username=username) @@ -374,8 +375,9 @@ def follow(request, username): @login_required -def unfollow(request, username): +def unfollow(request): ''' unfollow a user ''' + username = request.POST['user'] to_unfollow = models.User.objects.get(username=username) outgoing.handle_outgoing_unfollow(request.user, to_unfollow)