From 680e547c8b2285318cb3875337025741df1ee2e4 Mon Sep 17 00:00:00 2001 From: Hugh Rundle Date: Sat, 2 Oct 2021 21:24:26 +1000 Subject: [PATCH] add button for non-owner members to leave group --- bookwyrm/templates/groups/group.html | 5 +++-- bookwyrm/templates/groups/members.html | 18 +++++++++++++++++- bookwyrm/views/group.py | 2 +- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/bookwyrm/templates/groups/group.html b/bookwyrm/templates/groups/group.html index 4d1cdf79c..f19e8ee4f 100644 --- a/bookwyrm/templates/groups/group.html +++ b/bookwyrm/templates/groups/group.html @@ -10,8 +10,9 @@ {% block searchresults %} {% endblock %} - - {% include "groups/members.html" with group=group %} +
+ {% include "groups/members.html" with group=group %} +

Lists

{% if not lists %} diff --git a/bookwyrm/templates/groups/members.html b/bookwyrm/templates/groups/members.html index e005aba65..8c3dac7b4 100644 --- a/bookwyrm/templates/groups/members.html +++ b/bookwyrm/templates/groups/members.html @@ -2,6 +2,7 @@ {% load utilities %} {% load humanize %} {% load bookwyrm_tags %} +{% load bookwyrm_group_tags %}

Group Members

{% trans "Members can add and remove books on a group's book lists" %}

@@ -29,4 +30,19 @@ {% endwith %} {% endfor %} - \ No newline at end of file + + +{% if group.user != request.user and group|is_member:request.user %} +
+ {% csrf_token %} + + + +
+{% endif %} \ No newline at end of file diff --git a/bookwyrm/views/group.py b/bookwyrm/views/group.py index 17db93eda..cb21842b7 100644 --- a/bookwyrm/views/group.py +++ b/bookwyrm/views/group.py @@ -194,7 +194,7 @@ def remove_member(request): memberships = models.GroupMember.objects.filter(group=group) model = apps.get_model("bookwyrm.Notification", require_ready=True) - notification_type = "LEAVE" if "self_removal" in request.POST and request.POST["self_removal"] else "REMOVE" + notification_type = "LEAVE" if user == request.user else "REMOVE" # let the other members know about it for membership in memberships: member = membership.user