diff --git a/src/agenda_culturel/models.py b/src/agenda_culturel/models.py index cf70cb9..b4c858e 100644 --- a/src/agenda_culturel/models.py +++ b/src/agenda_culturel/models.py @@ -5,7 +5,7 @@ from django.utils.safestring import mark_safe from django.template.defaultfilters import slugify from django.urls import reverse from colorfield.fields import ColorField -from ckeditor.fields import RichTextField +from django_ckeditor_5.fields import CKEditor5Field from urllib.parse import urlparse import urllib.request import os @@ -46,8 +46,9 @@ class StaticContent(models.Model): max_length=512, unique=True, ) - text = RichTextField( - verbose_name=_("Content"), help_text=_("Text as shown to the visitors") + text = CKEditor5Field( + verbose_name=_("Content"), help_text=_("Text as shown to the visitors"), + blank=True ) url_path = models.CharField( verbose_name=_("URL path"), @@ -450,7 +451,7 @@ class Event(models.Model): first = self.start_day last = self.get_consolidated_end_day() calendar = CalendarList(first, last, exact=True) - return [(len(d.events), d.date) for dstr, d in calendar.calendar_days.items()] + return [(len(d.events), d.date) for dstr, d in calendar.get_calendar_days().items()] def is_single_day(self, intuitive=True): return self.start_day == self.get_consolidated_end_day(intuitive) @@ -1201,7 +1202,7 @@ class ContactMessage(models.Model): blank=True, null=True, ) - message = RichTextField(verbose_name=_("Message"), help_text=_("Your message")) + message = CKEditor5Field(verbose_name=_("Message"), help_text=_("Your message"), blank=True) date = models.DateTimeField(auto_now_add=True) @@ -1212,7 +1213,7 @@ class ContactMessage(models.Model): ), default=False, ) - comments = RichTextField( + comments = CKEditor5Field( verbose_name=_("Comments"), help_text=_("Comments on the message from the moderation team"), default="", diff --git a/src/agenda_culturel/settings/base.py b/src/agenda_culturel/settings/base.py index c080747..ef55575 100644 --- a/src/agenda_culturel/settings/base.py +++ b/src/agenda_culturel/settings/base.py @@ -47,7 +47,7 @@ INSTALLED_APPS = [ "django_better_admin_arrayfield", "django_filters", "compressor", - "ckeditor", + "django_ckeditor_5", "recurrence", "location_field.apps.DefaultConfig", "django.contrib.postgres", @@ -74,13 +74,12 @@ MIDDLEWARE = [ # "django.middleware.cache.FetchFromCacheMiddleware", ] -CKEDITOR_CONFIGS = { - "default": { - "toolbar": "full", - "removePlugins": "stylesheetparser", - "allowedContent": True, - }, -} +CKEDITOR_5_CONFIGS = { +'default': { + 'toolbar': ['heading', '|', 'bold', 'italic', 'link', '|', + 'bulletedList', 'numberedList', 'blockQuote',], + 'language': 'fr', + },} ROOT_URLCONF = "agenda_culturel.urls" diff --git a/src/agenda_culturel/templates/agenda_culturel/staticcontent_form.html b/src/agenda_culturel/templates/agenda_culturel/staticcontent_form.html index 4fcc327..93a6f4b 100644 --- a/src/agenda_culturel/templates/agenda_culturel/staticcontent_form.html +++ b/src/agenda_culturel/templates/agenda_culturel/staticcontent_form.html @@ -2,14 +2,6 @@ {% block title %}{% block og_title %}Modifier {{ object.name }}{% endblock %}{% endblock %} -{% block entete_header %} -{% load static %} - - - - - -{% endblock %} {% block content %} @@ -19,5 +11,6 @@ {{ form.as_p }} +{{ form.media }} {% endblock %} \ No newline at end of file diff --git a/src/agenda_culturel/urls.py b/src/agenda_culturel/urls.py index cca6f0c..565643f 100644 --- a/src/agenda_culturel/urls.py +++ b/src/agenda_culturel/urls.py @@ -173,6 +173,7 @@ urlpatterns = [ name="export_ical"), re_path(r'^robots\.txt', include('robots.urls')), path("__debug__/", include("debug_toolbar.urls")), + path("ckeditor5/", include('django_ckeditor_5.urls')), ] if settings.DEBUG: diff --git a/src/requirements.txt b/src/requirements.txt index a96768a..32f013c 100644 --- a/src/requirements.txt +++ b/src/requirements.txt @@ -32,6 +32,7 @@ django-filter==23.3 django-compressor==4.4 django-libsass==0.9 django-ckeditor==6.7.1 +django-ckeditor-5==0.2.13 django-recurrence==1.11.1 icalendar==5.0.11 lxml==5.1.0