X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/ff58bad61fad779f3eeedccd01de4e7c07d94f1c..6b6ff36189e97efb3b463643018806e9ff8e14a8:/src/catalogue/models.py?ds=inline diff --git a/src/catalogue/models.py b/src/catalogue/models.py index f492809f..be7c37f7 100644 --- a/src/catalogue/models.py +++ b/src/catalogue/models.py @@ -384,11 +384,8 @@ class Book(WikidataModel): for work_type in WorkType.objects.all() } - def scans_gallery(self): - bs = self.booksource_set.first() - if bs is None: - return '' - return bs.pk + def scans_galleries(self): + return [bs.pk for bs in self.booksource_set.all()] def is_published(self): return any(b.is_published() for b in self.document_books.all()) @@ -429,6 +426,15 @@ class Book(WikidataModel): self._content_stats = stats return stats + @property + def are_sources_ready(self): + if not self.booksource_set.exists(): + return False + for bs in self.booksource_set.all(): + if not bs.source.has_view_files() or not bs.source.has_ocr_files() or bs.source.modified_at > bs.source.processed_at: + return False + return True + chars = lambda self: self.content_stats.get('chars', '') chars_with_fn = lambda self: self.content_stats.get('chars_with_fn', '') words = lambda self: self.content_stats.get('words', '')