Add default draft warning to new articles

This commit is contained in:
Gabriel Augendre 2021-03-06 14:50:21 +01:00
parent 059e9b0322
commit d68f37fd33
2 changed files with 26 additions and 1 deletions

View file

@ -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 😊'
),
),
]

View file

@ -51,8 +51,13 @@ class Article(models.Model):
(DRAFT, "Draft"), (DRAFT, "Draft"),
(PUBLISHED, "Published"), (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) 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) status = models.CharField(max_length=15, choices=STATUS_CHOICES, default=DRAFT)
published_at = models.DateTimeField(null=True, blank=True) published_at = models.DateTimeField(null=True, blank=True)
created_at = models.DateTimeField(auto_now_add=True) created_at = models.DateTimeField(auto_now_add=True)