Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pinax/blog/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class PostAdmin(admin.ModelAdmin):
fields = [
"section",
"title",
"subtitle",
"slug",
"author",
"markup",
Expand Down
8 changes: 8 additions & 0 deletions pinax/blog/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"author",
"markup",
"title",
"subtitle",
"slug",
"teaser",
"content",
Expand Down Expand Up @@ -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
Expand All @@ -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%;"})
Expand Down Expand Up @@ -126,6 +133,7 @@ class Meta:
fields = [
"section",
"title",
"subtitle",
"teaser",
"content",
"description",
Expand Down
2 changes: 2 additions & 0 deletions pinax/blog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -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)),
Expand Down
10 changes: 10 additions & 0 deletions pinax/blog/migrations/0005_auto_20151218_1733.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down
2 changes: 2 additions & 0 deletions pinax/blog/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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"))
Expand Down
3 changes: 3 additions & 0 deletions pinax/blog/tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions pinax/blog/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -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",
Expand Down