From d68f37fd33bf3df75a5794c5fcfeb4204d0bacba Mon Sep 17 00:00:00 2001 From: Gabriel Augendre Date: Sat, 6 Mar 2021 14:50:21 +0100 Subject: [PATCH] Add default draft warning to new articles --- .../migrations/0031_auto_20210306_1449.py | 20 +++++++++++++++++++ articles/models.py | 7 ++++++- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 articles/migrations/0031_auto_20210306_1449.py diff --git a/articles/migrations/0031_auto_20210306_1449.py b/articles/migrations/0031_auto_20210306_1449.py new file mode 100644 index 0000000..38d709c --- /dev/null +++ b/articles/migrations/0031_auto_20210306_1449.py @@ -0,0 +1,20 @@ +# Generated by Django 3.1.5 on 2021-03-06 13:49 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("articles", "0030_tag_slug"), + ] + + operations = [ + migrations.AlterField( + model_name="article", + name="content", + field=models.TextField( + default='!!! warning "Draft"\n This article is still a draft. It may appear by error in your feed if I click on the "publish" button too early 😊' + ), + ), + ] diff --git a/articles/models.py b/articles/models.py index e5d960b..027b9df 100644 --- a/articles/models.py +++ b/articles/models.py @@ -51,8 +51,13 @@ class Article(models.Model): (DRAFT, "Draft"), (PUBLISHED, "Published"), ] + CONTENT_DEFAULT = ( + '!!! warning "Draft"\n' + " This article is still a draft. It may appear by error in your feed " + 'if I click on the "publish" button too early 😊' + ) title = models.CharField(max_length=255) - content = models.TextField() + content = models.TextField(default=CONTENT_DEFAULT) status = models.CharField(max_length=15, choices=STATUS_CHOICES, default=DRAFT) published_at = models.DateTimeField(null=True, blank=True) created_at = models.DateTimeField(auto_now_add=True)