X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/124258c72bb9e69e6336de195f3a3b3e74509b95..73ce961f14509aabfa26536f847afd28111029c6:/apps/catalogue/models.py diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 0c3513047..9a1e71ad0 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -688,8 +688,8 @@ class Book(models.Model): result = create_zip.delay(paths, "%s_%s" % (self.slug, format_)) return result.wait() - def search_index(self, book_info=None): - if hasattr(settings, 'CELERY_ALWAYS_EAGER') and settings.CELERY_ALWAYS_EAGER: + def search_index(self, book_info=None, reuse_index=False): + if reuse_index: idx = search.ReusableIndex() else: idx = search.Index() @@ -1022,6 +1022,24 @@ class Fragment(models.Model): return mark_safe(short_html) +class Collection(models.Model): + """A collection of books, which might be defined before publishing them.""" + title = models.CharField(_('title'), max_length=120, db_index=True) + slug = models.SlugField(_('slug'), max_length=120, primary_key=True) + description = models.TextField(_('description'), null=True, blank=True) + + models.SlugField(_('slug'), max_length=120, unique=True, db_index=True) + book_slugs = models.TextField(_('book slugs')) + + class Meta: + ordering = ('title',) + verbose_name = _('collection') + verbose_name_plural = _('collections') + + def __unicode__(self): + return self.title + + ########### # # SIGNALS