From 55e9b004673e1379b43589a254a5c33d518af31b Mon Sep 17 00:00:00 2001 From: Jarmil <jarmil.halamicek@seznam.cz> Date: Wed, 4 Nov 2020 11:41:35 +0100 Subject: [PATCH] nswebs: text clanku zmenen z Markdown na Richtext --- district/templates/shared/article.html | 4 ++-- shared/migrations/0014_auto_20201104_1134.py | 21 ++++++++++++++++++++ shared/models.py | 21 ++++++++++++++++---- 3 files changed, 40 insertions(+), 6 deletions(-) create mode 100644 shared/migrations/0014_auto_20201104_1134.py diff --git a/district/templates/shared/article.html b/district/templates/shared/article.html index 280672b9..632a69ad 100644 --- a/district/templates/shared/article.html +++ b/district/templates/shared/article.html @@ -1,5 +1,5 @@ {% extends "district/base.html" %} -{% load static wagtailcore_tags wagtailimages_tags shared_filters %} +{% load static wagtailcore_tags wagtailimages_tags %} {% block content %} @@ -45,7 +45,7 @@ <div class="lg:w-2/3"> <div itemprop="description" class="w-full content-block"> <p><strong>{{ page.perex }}</strong></p> - {{ page.text|markdown }} + {{ page.text|richtext }} </div> </div> diff --git a/shared/migrations/0014_auto_20201104_1134.py b/shared/migrations/0014_auto_20201104_1134.py new file mode 100644 index 00000000..25665646 --- /dev/null +++ b/shared/migrations/0014_auto_20201104_1134.py @@ -0,0 +1,21 @@ +# Generated by Django 3.1.1 on 2020-11-04 10:34 + +from django.db import migrations +import wagtail.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ("shared", "0013_auto_20201104_1053"), + ] + + operations = [ + migrations.AlterField( + model_name="article", + name="text", + field=wagtail.core.fields.RichTextField( + blank=True, verbose_name="text článku" + ), + ), + ] diff --git a/shared/models.py b/shared/models.py index 7ec838f0..66ba5012 100644 --- a/shared/models.py +++ b/shared/models.py @@ -4,6 +4,7 @@ import random import requests import requests_cache from django.core.validators import MaxValueValidator, MinValueValidator +from wagtail.core.fields import RichTextField from django.db import models from modelcluster.contrib.taggit import ClusterTaggableManager from modelcluster.fields import ParentalKey @@ -39,7 +40,22 @@ class ArticleMixin(models.Model): """ Spolecna pole vsech clanku """ perex = models.CharField("perex", max_length=250, blank=True) - text = models.TextField("text článku", blank=True) + text = RichTextField( + "text článku", + blank=True, + features=[ + "h1", + "h2", + "h3", + "h4", + "bold", + "italic", + "ol", + "ul", + "link", + "document-link", + ], + ) date = models.DateField("datum článku", blank=False, default=datetime.datetime.now) tags = ClusterTaggableManager(through=ArticleTag, blank=True) @@ -70,9 +86,6 @@ class Article(ArticleMixin, Page, SharedSubpageMixin, MetadataPageMixin): FieldPanel("perex"), FieldPanel("date"), FieldPanel("text"), - HelpPanel( - """Text článku lze formátovat s použitím <a href="https://www.markdownguide.org/basic-syntax/">markdown</a>""" - ), FieldPanel("author"), ImageChooserPanel("image"), FieldPanel("tags"), -- GitLab