add button for non-owner members to leave group

This commit is contained in:
Hugh Rundle 2021-10-02 21:24:26 +10:00
parent eed9d44cfd
commit 680e547c8b
3 changed files with 21 additions and 4 deletions

View file

@ -10,8 +10,9 @@
{% block searchresults %}
{% endblock %}
<div class="mb-2">
{% include "groups/members.html" with group=group %}
</div>
<h2 class="title is-5">Lists</h2>
{% if not lists %}

View file

@ -2,6 +2,7 @@
{% load utilities %}
{% load humanize %}
{% load bookwyrm_tags %}
{% load bookwyrm_group_tags %}
<h2 class="title is-5">Group Members</h2>
<p class="subtitle is-6">{% trans "Members can add and remove books on a group's book lists" %}</p>
@ -30,3 +31,18 @@
{% endwith %}
{% endfor %}
</div>
{% if group.user != request.user and group|is_member:request.user %}
<form action="{% url 'remove-group-member' %}" method="POST" class="my-4">
{% csrf_token %}
<input type="hidden" name="group" value="{{ group.id }}">
<input type="hidden" name="user" value="{{ user.username }}">
<button class="button is-small is-danger is-light" type="submit">
{% if show_username %}
{% blocktrans with username=user.localname %}Remove @{{ username }}{% endblocktrans %}
{% else %}
{% trans "Remove self from group" %}
{% endif %}
</button>
</form>
{% endif %}

View file

@ -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