+ def __iter__(self):
+ return iter(self.chunk_set.all())
+
+ def __getitem__(self, chunk):
+ return self.chunk_set.all()[chunk]
+
+ def __len__(self):
+ return self.chunk_set.count()
+
""" An editable chunk of text. Every Book text is divided into chunks. """
book = models.ForeignKey(Book)
number = models.IntegerField()
slug = models.SlugField()
comment = models.CharField(max_length=255)
""" An editable chunk of text. Every Book text is divided into chunks. """
book = models.ForeignKey(Book)
number = models.IntegerField()
slug = models.SlugField()
comment = models.CharField(max_length=255)
class Meta:
unique_together = [['book', 'number'], ['book', 'slug']]
class Meta:
unique_together = [['book', 'number'], ['book', 'slug']]
- def save(self, *args, **kwargs):
- if self.doc is None:
- self.doc = dvcs_models.Document.objects.create()
- super(Chunk, self).save(*args, **kwargs)
+ def get_absolute_url(self):
+ return reverse("wiki_editor", args=[self.book.slug, self.slug])
def pretty_name(self):
return "%s, %s (%d/%d)" % (self.book.title, self.comment,
def pretty_name(self):
return "%s, %s (%d/%d)" % (self.book.title, self.comment,