Skip to content

Commit

Permalink
replace django-ckedtitor with django-ckeditor-5
Browse files Browse the repository at this point in the history
  • Loading branch information
goapunk committed Nov 6, 2023
1 parent 010fbcd commit cb90ab1
Showing 14 changed files with 83 additions and 82 deletions.
17 changes: 2 additions & 15 deletions adhocracy4/ckeditor/fields.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,10 @@
from ckeditor.fields import RichTextField
from ckeditor_uploader.fields import RichTextUploadingField

_extra_plugins = ["collapsibleItem", "embed", "embedbase"]
_external_plugin_resources = [
(
"collapsibleItem",
"/static/ckeditor_collapsible/",
"plugin.js",
)
]


# FIXME: remove these fields / file
class RichTextCollapsibleMixin:
def __init__(self, *args, **kwargs):
kwargs["extra_plugins"] = kwargs.get("extra_plugins", []) + _extra_plugins
kwargs["external_plugin_resources"] = (
kwargs.get("external_plugin_resources", []) + _external_plugin_resources
)
super().__init__(*args, **kwargs)
pass


class RichTextCollapsibleField(RichTextCollapsibleMixin, RichTextField):
Binary file not shown.
Binary file not shown.
44 changes: 0 additions & 44 deletions adhocracy4/ckeditor/static/ckeditor_collapsible/plugin.js

This file was deleted.

6 changes: 3 additions & 3 deletions adhocracy4/projects/admin.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from ckeditor_uploader.widgets import CKEditorUploadingWidget
from django import forms
from django.contrib import admin
from django.utils.translation import gettext_lazy as _
from django_ckeditor_5.widgets import CKEditor5Widget

from . import models

@@ -37,10 +37,10 @@ class ProjectAdminForm(forms.ModelForm):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

self.fields["information"].widget = CKEditorUploadingWidget(
self.fields["information"].widget = CKEditor5Widget(
config_name="collapsible-image-editor"
)
self.fields["result"].widget = CKEditorUploadingWidget(
self.fields["result"].widget = CKEditor5Widget(
config_name="collapsible-image-editor"
)

31 changes: 31 additions & 0 deletions adhocracy4/projects/migrations/0040_auto_20230919_0952.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Generated by Django 3.2.20 on 2023-09-19 09:52

from django.db import migrations
import django_ckeditor_5.fields


class Migration(migrations.Migration):
dependencies = [
("a4projects", "0039_add_alt_text_to_field"),
]

operations = [
migrations.AlterField(
model_name="project",
name="information",
field=django_ckeditor_5.fields.CKEditor5Field(
blank=True,
help_text="This description should tell participants what the goal of the project is, how the project’s participation will look like. It will be always visible in the „Info“ tab on your project’s page.",
verbose_name="Description of your project",
),
),
migrations.AlterField(
model_name="project",
name="result",
field=django_ckeditor_5.fields.CKEditor5Field(
blank=True,
help_text="Here you should explain what the expected outcome of the project will be and how you are planning to use the results. If the project is finished you should add a summary of the results.",
verbose_name="Results of your project",
),
),
]
6 changes: 3 additions & 3 deletions adhocracy4/projects/models.py
Original file line number Diff line number Diff line change
@@ -9,11 +9,11 @@
from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.translation import gettext_lazy as _
from django_ckeditor_5.fields import CKEditor5Field
from django_enumfield.enum import EnumField

from adhocracy4 import transforms as html_transforms
from adhocracy4.administrative_districts.models import AdministrativeDistrict
from adhocracy4.ckeditor.fields import RichTextCollapsibleUploadingField
from adhocracy4.images import fields
from adhocracy4.maps.fields import PointField
from adhocracy4.models import base
@@ -194,7 +194,7 @@ class Project(
"in max. 250 chars."
),
)
information = RichTextCollapsibleUploadingField(
information = CKEditor5Field(
blank=True,
config_name="collapsible-image-editor",
verbose_name=_("Description of your project"),
@@ -205,7 +205,7 @@ class Project(
"in the „Info“ tab on your project’s page."
),
)
result = RichTextCollapsibleUploadingField(
result = CKEditor5Field(
blank=True,
config_name="collapsible-image-editor",
verbose_name=_("Results of your project"),
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -23,7 +23,7 @@ dependencies = [
"django-allauth",
"django-autoslug",
"django-background-tasks",
"django-ckeditor",
"django-ckeditor-5",
"django-enumfield",
"django-filter",
"django-multiselectfield",
1 change: 1 addition & 0 deletions requirements/base.txt
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ Django==3.2.20
django-allauth==0.54.0
git+https://github.com/liqd/django-autoslug.git@liqd2212#egg=django-autoslug
django-background-tasks==1.2.5
django-ckeditor-5==0.2.9
django-ckeditor==6.6.1
django-enumfield==3.1
django-filter==22.1
20 changes: 20 additions & 0 deletions tests/apps/ideas/migrations/0006_alter_idea_description.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 3.2.20 on 2023-09-19 13:10

from django.db import migrations
import django_ckeditor_5.fields


class Migration(migrations.Migration):
dependencies = [
("a4test_ideas", "0005_idea_is_bool_test"),
]

operations = [
migrations.AlterField(
model_name="idea",
name="description",
field=django_ckeditor_5.fields.CKEditor5Field(
blank=True, verbose_name="Description"
),
),
]
4 changes: 2 additions & 2 deletions tests/apps/ideas/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from ckeditor.fields import RichTextField
from django.contrib.contenttypes.fields import GenericRelation
from django.db import models
from django_ckeditor_5.fields import CKEditor5Field

from adhocracy4.categories.fields import CategoryField
from adhocracy4.comments.models import Comment
@@ -19,7 +19,7 @@ class IdeaQuerySet(RateableQuerySet, CommentableQuerySet):

class Idea(Item):
name = models.CharField(max_length=120, default="Can i haz cheezburger, pls?")
description = RichTextField(verbose_name="Description", blank=True)
description = CKEditor5Field(verbose_name="Description", blank=True)
moderator_status = models.CharField(max_length=256, blank=True)
moderator_feedback_text = models.OneToOneField(
ModeratorFeedback,
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.20 on 2023-09-19 13:10

from django.db import migrations
import django_ckeditor_5.fields


class Migration(migrations.Migration):
dependencies = [
("moderatorfeedback", "0004_verbose_name_created_modified"),
]

operations = [
migrations.AlterField(
model_name="moderatorfeedback",
name="feedback_text",
field=django_ckeditor_5.fields.CKEditor5Field(blank=True),
),
]
4 changes: 2 additions & 2 deletions tests/apps/moderatorfeedback/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from ckeditor.fields import RichTextField
from django_ckeditor_5.fields import CKEditor5Field

from adhocracy4.models.base import UserGeneratedContentModel


class ModeratorFeedback(UserGeneratedContentModel):
feedback_text = RichTextField(
feedback_text = CKEditor5Field(
blank=True,
)
12 changes: 0 additions & 12 deletions tests/ckeditor/test_ckeditor_fields.py

This file was deleted.

0 comments on commit cb90ab1

Please sign in to comment.