mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2024-12-04 07:16:36 +00:00
add group membership to raise_not_deletable for lists
This commit is contained in:
parent
602664b8d7
commit
77ac8e0c04
2 changed files with 4 additions and 8 deletions
|
@ -101,7 +101,6 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
|
||||||
notification_type="ADD",
|
notification_type="ADD",
|
||||||
)
|
)
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
if self.book_list.group:
|
if self.book_list.group:
|
||||||
for membership in self.book_list.group.memberships.all():
|
for membership in self.book_list.group.memberships.all():
|
||||||
if membership.user != self.user:
|
if membership.user != self.user:
|
||||||
|
@ -111,14 +110,16 @@ class ListItem(CollectionItemMixin, BookWyrmModel):
|
||||||
related_list_item=self,
|
related_list_item=self,
|
||||||
notification_type="ADD"
|
notification_type="ADD"
|
||||||
)
|
)
|
||||||
=======
|
|
||||||
def raise_not_deletable(self, viewer):
|
def raise_not_deletable(self, viewer):
|
||||||
"""the associated user OR the list owner can delete"""
|
"""the associated user OR the list owner can delete"""
|
||||||
if self.book_list.user == viewer:
|
if self.book_list.user == viewer:
|
||||||
return
|
return
|
||||||
|
# group members can delete items in group lists
|
||||||
|
is_group_member = models.GroupMember.objects.filter(group=self.book_list.group, user=viewer).exists()
|
||||||
|
if is_group_member:
|
||||||
|
return
|
||||||
super().raise_not_deletable(viewer)
|
super().raise_not_deletable(viewer)
|
||||||
|
|
||||||
>>>>>>> main
|
|
||||||
class Meta:
|
class Meta:
|
||||||
"""A book may only be placed into a list once,
|
"""A book may only be placed into a list once,
|
||||||
and each order in the list may be used only once"""
|
and each order in the list may be used only once"""
|
||||||
|
|
|
@ -341,11 +341,6 @@ def remove_book(request, list_id):
|
||||||
book_list = get_object_or_404(models.List, id=list_id)
|
book_list = get_object_or_404(models.List, id=list_id)
|
||||||
item = get_object_or_404(models.ListItem, id=request.POST.get("item"))
|
item = get_object_or_404(models.ListItem, id=request.POST.get("item"))
|
||||||
|
|
||||||
# TODO: put this logiv into raise_not_deletable
|
|
||||||
# is_group_member = models.GroupMember.objects.filter(group=book_list.group, user=request.user).exists()
|
|
||||||
# if not book_list.user == request.user and not item.user == request.user and not is_group_member:
|
|
||||||
# return HttpResponseNotFound()
|
|
||||||
|
|
||||||
item.raise_not_deletable(request.user)
|
item.raise_not_deletable(request.user)
|
||||||
|
|
||||||
with transaction.atomic():
|
with transaction.atomic():
|
||||||
|
|
Loading…
Reference in a new issue