diff --git a/pinax/blog/admin.py b/pinax/blog/admin.py index 085c199..83a874f 100644 --- a/pinax/blog/admin.py +++ b/pinax/blog/admin.py @@ -38,6 +38,7 @@ class PostAdmin(admin.ModelAdmin): fields = [ "section", "title", + "subtitle", "slug", "author", "markup", diff --git a/pinax/blog/forms.py b/pinax/blog/forms.py index ae7dd1d..5c94d3c 100644 --- a/pinax/blog/forms.py +++ b/pinax/blog/forms.py @@ -17,6 +17,7 @@ "author", "markup", "title", + "subtitle", "slug", "teaser", "content", @@ -62,6 +63,7 @@ def save_post(self, post): r = Revision() r.post = post r.title = post.title + r.subtitle = post.subtitle r.teaser = self.cleaned_data["teaser"] r.content = self.cleaned_data["content"] r.author = post.author @@ -82,6 +84,11 @@ class AdminPostForm(PostFormMixin, forms.ModelForm): max_length=90, widget=forms.TextInput(attrs={"style": "width: 50%;"}), ) + subtitle = forms.CharField( + label=_("Subtitle"), + max_length=90, + widget=forms.TextInput(attrs={"style": "width: 50%;"}), + ) slug = forms.CharField( label=_("Slug"), widget=forms.TextInput(attrs={"style": "width: 50%;"}) @@ -126,6 +133,7 @@ class Meta: fields = [ "section", "title", + "subtitle", "teaser", "content", "description", diff --git a/pinax/blog/migrations/0001_initial.py b/pinax/blog/migrations/0001_initial.py index bbb43ef..8d0f23f 100644 --- a/pinax/blog/migrations/0001_initial.py +++ b/pinax/blog/migrations/0001_initial.py @@ -42,6 +42,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('section', models.IntegerField(choices=[(1, 'all'), (2, b'Release Notes')])), ('title', models.CharField(max_length=90)), + ('subtitle', models.CharField(max_length=90)), ('slug', models.SlugField()), ('markup', models.CharField(max_length=25, choices=[('markdown', 'Markdown'), ('creole', 'Creole')])), ('teaser_html', models.TextField(editable=False)), @@ -80,6 +81,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('title', models.CharField(max_length=90)), + ('subtitle', models.CharField(max_length=90)), ('teaser', models.TextField()), ('content', models.TextField()), ('updated', models.DateTimeField(default=timezone.now)), diff --git a/pinax/blog/migrations/0005_auto_20151218_1733.py b/pinax/blog/migrations/0005_auto_20151218_1733.py index 985e4c1..8a7a49a 100644 --- a/pinax/blog/migrations/0005_auto_20151218_1733.py +++ b/pinax/blog/migrations/0005_auto_20151218_1733.py @@ -111,6 +111,11 @@ class Migration(migrations.Migration): name='title', field=models.CharField(max_length=90, verbose_name='Title'), ), + migrations.AlterField( + model_name='post', + name='subtitle', + field=models.CharField(max_length=90, verbose_name='Subtitle'), + ), migrations.AlterField( model_name='post', name='tweet_text', @@ -176,6 +181,11 @@ class Migration(migrations.Migration): name='title', field=models.CharField(max_length=90, verbose_name='Title'), ), + migrations.AlterField( + model_name='revision', + name='subtitle', + field=models.CharField(max_length=90, verbose_name='Subtitle'), + ), migrations.AlterField( model_name='revision', name='updated', diff --git a/pinax/blog/models.py b/pinax/blog/models.py index 160a5c9..a004d94 100644 --- a/pinax/blog/models.py +++ b/pinax/blog/models.py @@ -68,6 +68,7 @@ class Post(models.Model): section = models.ForeignKey(Section, on_delete=models.CASCADE) title = models.CharField(_("Title"), max_length=90) + subtitle = models.CharField(_("Subtitle"), max_length=90) slug = models.SlugField(_("Slug"), max_length=90, unique=settings.PINAX_BLOG_SLUG_UNIQUE) author = models.ForeignKey( settings.AUTH_USER_MODEL, @@ -227,6 +228,7 @@ class Revision(models.Model): ) title = models.CharField(_("Title"), max_length=90) + subtitle = models.CharField(_("Subtitle"), max_length=90) teaser = models.TextField(_("Teaser")) content = models.TextField(_("Content")) diff --git a/pinax/blog/tests/test_forms.py b/pinax/blog/tests/test_forms.py index e01a40c..a1f69df 100644 --- a/pinax/blog/tests/test_forms.py +++ b/pinax/blog/tests/test_forms.py @@ -23,15 +23,18 @@ def setUp(self): self.content = "You won't believe what happened next!" self.teaser = "Only his dog knows the truth" self.title_len = Post._meta.get_field("title").max_length + self.subtitle_len = Post._meta.get_field("subtitle").max_length def test_max_slug(self): """ Ensure Post can be created with slug same length as title. """ title = randomword(self.title_len) + subtitle = randomword(self.subtitle_len) form_data = { "section": self.section, "title": title, + "subtitle": subtitle, "content": self.content, "teaser": self.teaser, "state": 1 diff --git a/pinax/blog/tests/tests.py b/pinax/blog/tests/tests.py index 676d0c6..6db75e0 100644 --- a/pinax/blog/tests/tests.py +++ b/pinax/blog/tests/tests.py @@ -34,20 +34,24 @@ def setUp(self): # Create two published Posts, one in each section. self.orange_title = "Orange You Wonderful" + self.orange_subtitle = "Subtitle for you orange" self.orange_slug = slugify(self.orange_title) self.orange_post = Post.objects.create(blog=self.blog, section=self.oranges, title=self.orange_title, + subtitle=self.orange_subtitle, slug=self.orange_slug, author=self.user, markup=self.markup, state=Post.STATE_CHOICES[-1][0]) self.apple_title = "Apple of My Eye" + self.apple_subtitle = "Subtitle for you apple" self.apple_slug = slugify(self.apple_title) self.apple_post = Post.objects.create(blog=self.blog, section=self.apples, title=self.apple_title, + subtitle=self.apple_subtitle, slug=self.apple_slug, author=self.user, markup=self.markup, @@ -105,11 +109,14 @@ class TestModelFieldValidation(TestBlog): def test_overlong_slug(self): title_len = Post._meta.get_field("title").max_length title = randomword(title_len) + subtitle_len = Post._meta.get_field("subtitle").max_length + subtitle = randomword(subtitle_len) slug_len = Post._meta.get_field("slug").max_length slug = randomword(slug_len + 1) slug_post = Post(blog=self.blog, section=self.apples, title=title, + subtitle=subtitle, slug=slug, author=self.user, state=Post.STATE_CHOICES[-1][0]) @@ -165,9 +172,11 @@ def test_manage_post_create_post(self): self.user.is_staff = True self.user.save() post_title = "You'll never believe what happened next!" + post_subtitle = "never believe what happened subtitle!" post_data = dict( section=self.apples.pk, title=post_title, + subtitle=post_subtitle, teaser="teaser", content="content", description="description",