X-Git-Url: https://git.mdrn.pl/redakcja.git/blobdiff_plain/30cd6983d7c3ce7a593d3f3c09560679ce1d3f26..16c9ae80956b9dd492a3b162a2b030070adb61c2:/apps/catalogue/models/book.py diff --git a/apps/catalogue/models/book.py b/apps/catalogue/models/book.py index 25b9304e..f07c9a83 100755 --- a/apps/catalogue/models/book.py +++ b/apps/catalogue/models/book.py @@ -13,7 +13,7 @@ from slughifi import slughifi import apiclient from catalogue.helpers import cached_in_field, GalleryMerger -from catalogue.models import BookPublishRecord, ChunkPublishRecord +from catalogue.models import BookPublishRecord, ChunkPublishRecord, Project from catalogue.signals import post_publish from catalogue.tasks import refresh_instance, book_content_updated from catalogue.xml_tools import compile_text, split_xml @@ -28,7 +28,8 @@ class Book(models.Model): title = models.CharField(_('title'), max_length=255, db_index=True) slug = models.SlugField(_('slug'), max_length=128, unique=True, db_index=True) public = models.BooleanField(_('public'), default=True, db_index=True) - gallery = models.CharField(_('scan gallery name'), max_length=255, blank=True) + gallery = models.CharField(u'materiały', max_length=255, blank=True) + project = models.ForeignKey(Project, null=True, blank=True) #wl_slug = models.CharField(_('title'), max_length=255, null=True, db_index=True, editable=False) parent = models.ForeignKey('self', null=True, blank=True, verbose_name=_('parent'), related_name="children", editable=False) @@ -51,8 +52,8 @@ class Book(models.Model): class Meta: app_label = 'catalogue' ordering = ['title', 'slug'] - verbose_name = _('book') - verbose_name_plural = _('books') + verbose_name = u'moduł' + verbose_name_plural = u'moduły' # Representing @@ -205,7 +206,8 @@ class Book(models.Model): # and move the gallery starts if gm.was_merged: for chunk in self[len(self) - len_other:]: - chunk.gallery_start += gm.dest_size - gm.num_deleted + old_start = chunk.gallery_start or 1 + chunk.gallery_start = old_start + gm.dest_size - gm.num_deleted chunk.save() other.delete() @@ -270,6 +272,14 @@ class Book(models.Model): valid_about = self.correct_about() assert bi.about == valid_about, _("rdf:about is not") + " " + valid_about + def publishable_error(self): + try: + return self.assert_publishable() + except AssertionError, e: + return e + else: + return None + def hidden(self): return self.slug.startswith('.')