From d5011c4876bdae561f396c64cac6503ad51d5fa5 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 22 Sep 2011 16:10:17 +0200 Subject: [PATCH] rename Chunk.comment to Chunk.title --- .../management/commands/merge_books.py | 4 ++-- apps/catalogue/migrations/0001_initial.py | 4 ++-- apps/catalogue/migrations/0002_from_hg.py | 2 +- apps/catalogue/models.py | 20 +++++++++---------- .../templates/catalogue/book_detail.html | 2 +- .../templates/catalogue/document_list.html | 2 +- apps/catalogue/views.py | 4 ++-- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/catalogue/management/commands/merge_books.py b/apps/catalogue/management/commands/merge_books.py index 8ec91f76..4747591c 100755 --- a/apps/catalogue/management/commands/merge_books.py +++ b/apps/catalogue/management/commands/merge_books.py @@ -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() diff --git a/apps/catalogue/migrations/0001_initial.py b/apps/catalogue/migrations/0001_initial.py index 2ffc684c..8bd220ad 100644 --- a/apps/catalogue/migrations/0001_initial.py +++ b/apps/catalogue/migrations/0001_initial.py @@ -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'}), diff --git a/apps/catalogue/migrations/0002_from_hg.py b/apps/catalogue/migrations/0002_from_hg.py index b19df625..2a64819e 100644 --- a/apps/catalogue/migrations/0002_from_hg.py +++ b/apps/catalogue/migrations/0002_from_hg.py @@ -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'}), diff --git a/apps/catalogue/models.py b/apps/catalogue/models.py index 69d0a0d3..00e1d300 100644 --- a/apps/catalogue/models.py +++ b/apps/catalogue/models.py @@ -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 diff --git a/apps/catalogue/templates/catalogue/book_detail.html b/apps/catalogue/templates/catalogue/book_detail.html index aac190ad..b93fce45 100755 --- a/apps/catalogue/templates/catalogue/book_detail.html +++ b/apps/catalogue/templates/catalogue/book_detail.html @@ -9,7 +9,7 @@ {% for c in chunks %} - + + {{ chunk.title }}
{{ c.chunk.comment }}{{ c.chunk.title }} {% for fix in c.fix %} {% ifequal fix "wl" %}[c] {{ chunk.number }}. - {{ chunk.comment }} {% if chunk.stage %} {{ chunk.stage }} {% else %} diff --git a/apps/catalogue/views.py b/apps/catalogue/views.py index 18682ebe..81de5ac7 100644 --- a/apps/catalogue/views.py +++ b/apps/catalogue/views.py @@ -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={ -- 2.20.1