X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..274de65ca44c680c6c555c599ec32428c79db356:/src/catalogue/models/book.py diff --git a/src/catalogue/models/book.py b/src/catalogue/models/book.py index 5f68e09ff..9381afc94 100644 --- a/src/catalogue/models/book.py +++ b/src/catalogue/models/book.py @@ -55,8 +55,8 @@ class Book(models.Model): extra_info = jsonfield.JSONField(_('extra information'), default={}) gazeta_link = models.CharField(blank=True, max_length=240) wiki_link = models.CharField(blank=True, max_length=240) - # files generated during publication + # files generated during publication cover = EbookField('cover', _('cover'), null=True, blank=True, upload_to=_cover_upload_to, @@ -96,6 +96,15 @@ class Book(models.Model): def __unicode__(self): return self.title + def get_initial(self): + try: + return re.search(r'\w', self.title, re.U).group(0) + except AttributeError: + return '' + + def author_str(self): + return ", ".join(str(t) for t in self.tags.filter(category='author')) + def save(self, force_insert=False, force_update=False, **kwargs): from sortify import sortify @@ -311,6 +320,7 @@ class Book(models.Model): notify_cover_changed.append(child) cls.repopulate_ancestors() + tasks.update_counters.delay() # No saves beyond this point.