X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/33af401eb4abe15a37d0147807d06a9b19eaa802..0eedef1eafceaaa3f4f78b014236bf642be2807b:/src/catalogue/models/book.py diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index 01f02816a..97677bdee 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -226,6 +226,11 @@ class Book(models.Model): def isbn_mobi(self): return self.get_extra_info_json().get('isbn_mobi') + def is_accessible_to(self, user): + if not self.preview: + return True + Membership = apps.get_model('club', 'Membership') + return Membership.is_active_for(user) def save(self, force_insert=False, force_update=False, **kwargs): from sortify import sortify @@ -738,6 +743,8 @@ class Book(models.Model): def update_references(self): from references.models import Entity, Reference master = self.get_master() + if master is None: + master = [] found = set() for i, sec in enumerate(master): for ref in sec.findall('.//ref'):