From b285fb2fc09a1f7eb2123fd6d3bebb320bf7a4c7 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Tue, 16 Mar 2021 13:37:22 -0700 Subject: [PATCH] Set shelf user by default --- bookwyrm/models/shelf.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bookwyrm/models/shelf.py b/bookwyrm/models/shelf.py index 965541a29..3185b47f7 100644 --- a/bookwyrm/models/shelf.py +++ b/bookwyrm/models/shelf.py @@ -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"""