Use form for saving list items
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
import uuid
|
||||
|
||||
from django.apps import apps
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.db import models
|
||||
from django.db.models import Q
|
||||
from django.utils import timezone
|
||||
@ -74,6 +75,22 @@ class List(OrderedCollectionMixin, BookWyrmModel):
|
||||
return
|
||||
super().raise_not_editable(viewer)
|
||||
|
||||
def raise_not_submittable(self, viewer):
|
||||
"""can the user submit a book to the list?"""
|
||||
# if you can't view the list you can't submit to it
|
||||
self.raise_visible_to_user(viewer)
|
||||
|
||||
# all good if you're the owner or the list is open
|
||||
if self.user == viewer or self.curation in ["open", "curated"]:
|
||||
return
|
||||
if self.curation == "group":
|
||||
is_group_member = GroupMember.objects.filter(
|
||||
group=self.group, user=viewer
|
||||
).exists()
|
||||
if is_group_member:
|
||||
return
|
||||
raise PermissionDenied()
|
||||
|
||||
@classmethod
|
||||
def followers_filter(cls, queryset, viewer):
|
||||
"""Override filter for "followers" privacy level to allow non-following
|
||||
|
Reference in New Issue
Block a user