X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/a1f86966aff87868cbc419b2d1a55d505aead21d..94da7eb2739d91e80607681bc61672ef769ca90c:/src/catalogue/models.py?ds=sidebyside diff --git a/src/catalogue/models.py b/src/catalogue/models.py index 7a203dd9..6f4fa1e9 100644 --- a/src/catalogue/models.py +++ b/src/catalogue/models.py @@ -138,6 +138,7 @@ class NotableBook(OrderableModel): class Category(WikidataModel): name = models.CharField(_("name"), max_length=255) slug = models.SlugField(max_length=255, unique=True) + description = models.TextField(_("description"), blank=True, help_text=_('for publication')) class Meta: abstract = True @@ -287,6 +288,18 @@ class Book(WikidataModel): def translators_last_names(self): return ', '.join(a.last_name for a in self.translators.all()) + def document_book__project(self): + b = self.document_books.first() + if b is None: return '' + if b.project is None: return '' + return b.project.name + + def audience(self): + try: + return self.document_books.first().wldocument().book_info.audience or '' + except: + return '' + def get_estimated_costs(self): return { work_type: work_type.calculate(self) @@ -307,6 +320,9 @@ class Book(WikidataModel): if pbr is not None and pbr.timestamp.date() > cutoff: months = (this_month - pbr.timestamp.date()).days / 365 * 12 + if not months: + return + stats = self.bookmonthlystats_set.filter(date__gte=cutoff).aggregate( views_page=models.Sum('views_page'), views_reader=models.Sum('views_reader')