from django.db import models
from django.db.models import permalink
import django.dispatch
+from django.core.urlresolvers import reverse
from django.utils.datastructures import SortedDict
from django.utils.translation import ugettext_lazy as _
import jsonfield
if old_cover:
notify_cover_changed.append(child)
- # delete old fragments when overwriting
- book.fragments.all().delete()
- # Build HTML, fix the tree tags, build cover.
- has_own_text = bool(book.html_file.build())
- tasks.fix_tree_tags.delay(book)
+ # No saves beyond this point.
+
+ # Build cover.
if 'cover' not in dont_build:
book.cover.build_delay()
book.cover_thumb.build_delay()
- # No saves behind this point.
-
- if has_own_text:
+ # Build HTML and ebooks.
+ if not children:
+ book.html_file.build_delay()
for format_ in constants.EBOOK_FORMATS_WITHOUT_CHILDREN:
if format_ not in dont_build:
getattr(book, '%s_file' % format_).build_delay()
audiences = sorted(set([self._audiences_pl.get(a, (99, a)) for a in audiences]))
return [a[1] for a in audiences]
+ def stage_note(self):
+ stage = self.extra_info.get('stage')
+ if stage and stage < '0.4':
+ return (_('This work needs modernisation'),
+ reverse('infopage', args=['wymagajace-uwspolczesnienia']))
+ else:
+ return None, None
+
def choose_fragment(self):
tag = self.book_tag()
fragments = Fragment.tagged.with_any([tag])