fix group members not being able to delete items on group lists

This commit is contained in:
Hugh Rundle 2021-10-03 12:22:03 +11:00
parent 7db2af89dd
commit 603a9dc25c
2 changed files with 4 additions and 3 deletions

View file

@ -1,4 +1,5 @@
""" make a list of books!! """
from bookwyrm.models.group import GroupMember
from dataclasses import field
from django.apps import apps
from django.db import models
@ -9,7 +10,7 @@ from bookwyrm.settings import DOMAIN
from .activitypub_mixin import CollectionItemMixin, OrderedCollectionMixin
from .base_model import BookWyrmModel
from . import fields
from .group import GroupMember
CurationType = models.TextChoices(
"Curation",
@ -115,7 +116,7 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
if self.book_list.user == viewer:
return
# group members can delete items in group lists
is_group_member = models.GroupMember.objects.filter(group=self.book_list.group, user=viewer).exists()
is_group_member = GroupMember.objects.filter(group=self.book_list.group, user=viewer).exists()
if is_group_member:
return
super().raise_not_deletable(viewer)

View file

@ -85,7 +85,7 @@
</form>
</div>
{% endif %}
{% if list.user == request.user or list.curation == 'open' and item.user == request.user %}
{% if list.user == request.user or list.curation == 'open' and item.user == request.user or list.group|is_member:request.user %}
<form name="remove-book" method="post" action="{% url 'list-remove-book' list.id %}" class="card-footer-item">
{% csrf_token %}
<input type="hidden" name="item" value="{{ item.id }}">