mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-23 00:26:33 +00:00
Merge pull request #62 from cthulahoops/follow
Always pass follow/unfollow parameter using POST.
This commit is contained in:
commit
5b13959850
3 changed files with 12 additions and 8 deletions
|
@ -12,13 +12,15 @@
|
|||
{% endif %}
|
||||
{% if not is_self %}
|
||||
{% if not request.user in user.followers.all %}
|
||||
<form action="/follow/{{ user.username }}" method="post">
|
||||
<form action="/follow/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ user.username }}"></input>
|
||||
<input type="submit" value="Follow"></input>
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="/unfollow/{{ user.username }}" method="post">
|
||||
<form action="/unfollow/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ user.username }}"></input>
|
||||
<input type="submit" value="Unfollow"></input>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
@ -38,13 +40,13 @@
|
|||
{% if not request.user in follower.followers.all %}
|
||||
<form action="/follow/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ follower.id }}"></input>
|
||||
<input type="hidden" name="user" value="{{ follower.username }}"></input>
|
||||
<input type="submit" value="Follow"></input>
|
||||
</form>
|
||||
{% else %}
|
||||
<form action="/unfollow/" method="post">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="user" value="{{ follower.id }}"></input>
|
||||
<input type="hidden" name="user" value="{{ follower.username }}"></input>
|
||||
<input type="submit" value="Unfollow"></input>
|
||||
</form>
|
||||
{% endif %}
|
||||
|
|
|
@ -57,8 +57,8 @@ urlpatterns = [
|
|||
re_path(r'^comment/?$', views.comment),
|
||||
re_path(r'^favorite/(?P<status_id>\d+)/?$', views.favorite),
|
||||
re_path(r'^shelve/?$', views.shelve),
|
||||
re_path(r'^follow/(?P<username>[\w@\.-]+)/?$', views.follow),
|
||||
re_path(r'^unfollow/(?P<username>[\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),
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue