Librarian in regular requirements.
[redakcja.git] / apps / catalogue / models / chunk.py
index 9b1dcba..fc3a9ea 100755 (executable)
@@ -11,7 +11,6 @@ from django.utils.translation import ugettext_lazy as _
 from catalogue.helpers import cached_in_field
 from catalogue.managers import VisibleManager
 from catalogue.tasks import refresh_instance
 from catalogue.helpers import cached_in_field
 from catalogue.managers import VisibleManager
 from catalogue.tasks import refresh_instance
-from catalogue.xml_tools import GradedText
 from dvcs import models as dvcs_models
 
 
 from dvcs import models as dvcs_models
 
 
@@ -23,7 +22,7 @@ class Chunk(dvcs_models.Document):
     number = models.IntegerField(_('number'))
     title = models.CharField(_('title'), max_length=255, blank=True)
     slug = models.SlugField(_('slug'))
     number = models.IntegerField(_('number'))
     title = models.CharField(_('title'), max_length=255, blank=True)
     slug = models.SlugField(_('slug'))
-    gallery_start = models.IntegerField(_('gallery start'), null=True, blank=True)
+    gallery_start = models.IntegerField(_('gallery start'), null=True, blank=True, default=1)
 
     # cache
     _short_html = models.TextField(null=True, blank=True, editable=False)
 
     # cache
     _short_html = models.TextField(null=True, blank=True, editable=False)
@@ -50,7 +49,7 @@ class Chunk(dvcs_models.Document):
 
     @models.permalink
     def get_absolute_url(self):
 
     @models.permalink
     def get_absolute_url(self):
-        return ("wiki_editor", [self.book.slug, self.slug])
+        return "wiki_editor", [self.book.slug, self.slug]
 
     def pretty_name(self, book_length=None):
         title = self.book.title
 
     def pretty_name(self, book_length=None):
         title = self.book.title
@@ -60,7 +59,6 @@ class Chunk(dvcs_models.Document):
             title += " (%d/%d)" % (self.number, book_length)
         return title
 
             title += " (%d/%d)" % (self.number, book_length)
         return title
 
-
     # Creating and manipulation
     # =========================
 
     # Creating and manipulation
     # =========================
 
@@ -72,7 +70,8 @@ class Chunk(dvcs_models.Document):
         while not new_chunk:
             new_slug = self.book.make_chunk_slug(slug)
             try:
         while not new_chunk:
             new_slug = self.book.make_chunk_slug(slug)
             try:
-                new_chunk = self.book.chunk_set.create(number=self.number+1,
+                new_chunk = self.book.chunk_set.create(
+                    number=self.number+1,
                     slug=new_slug[:50], title=title[:255], **kwargs)
             except IntegrityError:
                 pass
                     slug=new_slug[:50], title=title[:255], **kwargs)
             except IntegrityError:
                 pass
@@ -85,7 +84,6 @@ class Chunk(dvcs_models.Document):
         else:
             return cls.objects.get(book__slug=book_slug, slug=chunk_slug)
 
         else:
             return cls.objects.get(book__slug=book_slug, slug=chunk_slug)
 
-
     # State & cache
     # =============
 
     # State & cache
     # =============
 
@@ -93,7 +91,7 @@ class Chunk(dvcs_models.Document):
         change = self.publishable()
         if not change:
             return False
         change = self.publishable()
         if not change:
             return False
-        return change.publish_log.exists()
+        return not change.publish_log.exists()
 
     def is_changed(self):
         if self.head is None:
 
     def is_changed(self):
         if self.head is None:
@@ -124,6 +122,3 @@ class Chunk(dvcs_models.Document):
         self.changed
         self.hidden
         self.short_html
         self.changed
         self.hidden
         self.short_html
-
-    def graded(self, master=None):
-        return GradedText(self.materialize(), master)