Set shelf user by default

This commit is contained in:
Mouse Reeve 2021-03-16 13:37:22 -07:00
parent b816c322b5
commit b285fb2fc0

View file

@ -68,6 +68,11 @@ class ShelfBook(CollectionItemMixin, BookWyrmModel):
object_field = "book"
collection_field = "shelf"
def save(self, *args, **kwargs):
if not self.user:
self.user = self.shelf.user
super().save(*args, **kwargs)
class Meta:
"""an opinionated constraint!
you can't put a book on shelf twice"""