rename Chunk.comment to Chunk.title
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 22 Sep 2011 14:10:17 +0000 (16:10 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 22 Sep 2011 14:10:17 +0000 (16:10 +0200)
apps/catalogue/management/commands/merge_books.py
apps/catalogue/migrations/0001_initial.py
apps/catalogue/migrations/0002_from_hg.py
apps/catalogue/models.py
apps/catalogue/templates/catalogue/book_detail.html
apps/catalogue/templates/catalogue/document_list.html
apps/catalogue/views.py

index 8ec91f7..4747591 100755 (executable)
@@ -154,7 +154,7 @@ class Command(BaseCommand):
 
                 if verbose:
                     print "title: %s // %s  -->\n       %s // %s\nslug: %s / %s  -->\n      %s / %s" % (
-                        book.title, chunk.comment,
+                        book.title, chunk.title,
                         new_title, new_chunk_title,
                         book.slug, chunk.slug,
                         new_slug, new_chunk_slug)
@@ -168,7 +168,7 @@ class Command(BaseCommand):
                     book.slug = new_slug
                     book.save()
                     for j, chunk in enumerate(book):
-                        chunk.comment = chunk_titles[j]
+                        chunk.title = chunk_titles[j]
                         chunk.slug = chunk_slugs[j]
                         chunk.save()
 
index 2ffc684..8bd220a 100644 (file)
@@ -28,7 +28,7 @@ class Migration(SchemaMigration):
             ('book', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['catalogue.Book'])),
             ('number', self.gf('django.db.models.fields.IntegerField')()),
             ('slug', self.gf('django.db.models.fields.SlugField')(max_length=50, db_index=True)),
-            ('comment', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
+            ('title', self.gf('django.db.models.fields.CharField')(max_length=255, blank=True)),
             ('stage', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['catalogue.ChunkTag'], null=True, blank=True)),
             ('head', self.gf('django.db.models.fields.related.ForeignKey')(default=None, to=orm['catalogue.ChunkChange'], null=True, blank=True)),
         ))
@@ -181,7 +181,7 @@ class Migration(SchemaMigration):
         'catalogue.chunk': {
             'Meta': {'ordering': "['number']", 'unique_together': "[['book', 'number'], ['book', 'slug']]", 'object_name': 'Chunk'},
             'book': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Book']"}),
-            'comment': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
             'creator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'created_documents'", 'null': 'True', 'to': "orm['auth.User']"}),
             'head': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['catalogue.ChunkChange']", 'null': 'True', 'blank': 'True'}),
             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
index b19df62..2a64819 100644 (file)
@@ -223,7 +223,7 @@ class Migration(DataMigration):
         'catalogue.chunk': {
             'Meta': {'ordering': "['number']", 'unique_together': "[['book', 'number'], ['book', 'slug']]", 'object_name': 'Chunk'},
             'book': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Book']"}),
-            'comment': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
+            'title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'blank': 'True'}),
             'creator': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'created_documents'", 'null': 'True', 'to': "orm['auth.User']"}),
             'head': ('django.db.models.fields.related.ForeignKey', [], {'default': 'None', 'to': "orm['catalogue.ChunkChange']", 'null': 'True', 'blank': 'True'}),
             'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
index 69d0a0d..00e1d30 100644 (file)
@@ -69,7 +69,7 @@ class Book(models.Model):
             if i < book_len:
                 chunk = instance[i]
                 chunk.slug = slug
-                chunk.comment = title
+                chunk.title = title
                 chunk.save()
             else:
                 chunk = instance.add(slug, title, creator, adjust_slug=True)
@@ -191,17 +191,17 @@ class Book(models.Model):
                 if single:
                     # special treatment for appending one-parters:
                     # just use the guessed title and original book slug
-                    chunk.comment = other_title_part
+                    chunk.title = other_title_part
                     if other.slug.startswith(self.slug):
                         chunk_slug = other.slug[len(self.slug):].lstrip('-_')
                     else:
                         chunk_slug = other.slug
                     chunk.slug = self.make_chunk_slug(chunk_slug)
                 else:
-                    chunk.comment = "%s, %s" % (other_title_part, chunk.comment)
+                    chunk.title = "%s, %s" % (other_title_part, chunk.title)
             else:
                 chunk.slug = slugs[i]
-                chunk.comment = titles[i]
+                chunk.title = titles[i]
 
             chunk.slug = self.make_chunk_slug(chunk.slug)
             chunk.save()
@@ -226,14 +226,14 @@ class Chunk(dvcs_models.Document):
     book = models.ForeignKey(Book, editable=False)
     number = models.IntegerField()
     slug = models.SlugField()
-    comment = models.CharField(max_length=255, blank=True)
+    title = models.CharField(max_length=255, blank=True)
 
     class Meta:
         unique_together = [['book', 'number'], ['book', 'slug']]
         ordering = ['number']
 
     def __unicode__(self):
-        return "%d-%d: %s" % (self.book_id, self.number, self.comment)
+        return "%d:%d: %s" % (self.book_id, self.number, self.title)
 
     def get_absolute_url(self):
         return reverse("wiki_editor", args=[self.book.slug, self.slug])
@@ -247,13 +247,13 @@ class Chunk(dvcs_models.Document):
 
     def pretty_name(self, book_length=None):
         title = self.book.title
-        if self.comment:
-            title += ", %s" % self.comment
+        if self.title:
+            title += ", %s" % self.title
         if book_length > 1:
             title += " (%d/%d)" % (self.number, book_length)
         return title
 
-    def split(self, slug, comment='', creator=None, adjust_slug=False):
+    def split(self, slug, title='', creator=None, adjust_slug=False):
         """ Create an empty chunk after this one """
         self.book.chunk_set.filter(number__gt=self.number).update(
                 number=models.F('number')+1)
@@ -262,7 +262,7 @@ class Chunk(dvcs_models.Document):
             new_slug = self.book.make_chunk_slug(slug)
             try:
                 new_chunk = self.book.chunk_set.create(number=self.number+1,
-                    creator=creator, slug=new_slug, comment=comment)
+                    creator=creator, slug=new_slug, title=title)
             except IntegrityError:
                 pass
         return new_chunk
index aac190a..b93fce4 100755 (executable)
@@ -9,7 +9,7 @@
 <table>
     {% for c in chunks %}
         <tr class="chunk-{{ c.grade }}">
-        <td><a target="_blank" href="{{ c.chunk.get_absolute_url }}">{{ c.chunk.comment }}</a></td>
+        <td><a target="_blank" href="{{ c.chunk.get_absolute_url }}">{{ c.chunk.title }}</a></td>
         <td>{% for fix in c.fix %}
 
                 {% ifequal fix "wl" %}<span class="fix"
index 30c3e27..01e5a24 100644 (file)
@@ -102,7 +102,7 @@ $(function() {
                         <td><a href="{% url catalogue_chunk_edit book.slug chunk.slug %}">[c]</a></td>
                         <td><a target="_blank" href="{{ chunk.get_absolute_url }}">
                                 <span class='chunkno'>{{ chunk.number }}.</span>
-                                {{ chunk.comment }}</a></td>
+                                {{ chunk.title }}</a></td>
                         <td>{% if chunk.stage %}
                                 {{ chunk.stage }}
                             {% else %}
index 18682eb..81de5ac 100644 (file)
@@ -356,14 +356,14 @@ def chunk_add(request, slug, chunk):
                 creator = None
             doc.split(creator=creator,
                 slug=form.cleaned_data['slug'],
-                comment=form.cleaned_data['comment'],
+                title=form.cleaned_data['title'],
             )
 
             return http.HttpResponseRedirect(doc.book.get_absolute_url())
     else:
         form = forms.ChunkAddForm(initial={
                 "slug": str(doc.number + 1),
-                "comment": "cz. %d" % (doc.number + 1, ),
+                "title": "cz. %d" % (doc.number + 1, ),
         })
 
     return direct_to_template(request, "catalogue/chunk_add.html", extra_context={