X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/1249091e84840ca27aa6047db36c8e899328f15c..df60910b2d457f031cbe0a153e51e7378c0165d8:/src/catalogue/models/book.py diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index d3eddfd71..2371103e7 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -229,8 +229,15 @@ class Book(models.Model): def is_accessible_to(self, user): if not self.preview: return True + if not user.is_authenticated: + return False Membership = apps.get_model('club', 'Membership') - return Membership.is_active_for(user) + if Membership.is_active_for(user): + return True + Funding = apps.get_model('funding', 'Funding') + if Funding.objects.filter(user=user, offer__book=self): + return True + return False def save(self, force_insert=False, force_update=False, **kwargs): from sortify import sortify