Skip to content

Commit

Permalink
fix: Source maps and djangocms-text-ckeditor plugin migration (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun authored Aug 20, 2024
1 parent 0affa2c commit 091239e
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 17 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
Changelog
=========

0.2.1 (20-08-2024)
==================
0.2.2 / 0.2.1 (20-08-2024)
==========================

* fix: Let the migration only convert djangocms-text-ckeditor plugins if a corresponding table exists in the database
* fix: Let webpack import js map files from node libraries to remove references to non-existing map files in the js bundles
* fix: Unnecessary call to `static` in widget Media class made djangocms-text fail with manifest file storages

0.2.0 (24-07-2024)
Expand Down
2 changes: 1 addition & 1 deletion djangocms_text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
9. Publish the release when ready
10. Github actions will publish the new package to pypi
"""
__version__ = "0.2.1"
__version__ = "0.2.2"
9 changes: 3 additions & 6 deletions djangocms_text/migrations/0003_auto_20240702_1409.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Django 3.2.25 on 2024-07-02 14:09

from django.db import migrations, models, OperationalError
from django.db import migrations, models


def migrate_text_ckeditor_fields(apps, schema_editor):
Expand All @@ -20,17 +20,13 @@ class Meta:
json = models.JSONField(blank=True, null=True)
rte = models.CharField(max_length=16, blank=True)

try:
if CKEditorText._meta.db_table in schema_editor.connection.introspection.table_names():
existing_texts = Text_Text.objects.all().values_list("cmsplugin_ptr_id", flat=True)
qs = CKEditorText.objects.using(schema_editor.connection.alias).exclude(cmsplugin_ptr_id__in=existing_texts)
Text_Text.objects.using(schema_editor.connection.alias).bulk_create(
Text_Text(body=ckeditor_text.body, rte="text_ckeditor4", cmsplugin_ptr_id=ckeditor_text.cmsplugin_ptr_id)
for ckeditor_text in qs
)
except OperationalError as e:
if "no such table" in str(e):
return
raise e


class Migration(migrations.Migration):
Expand All @@ -42,5 +38,6 @@ class Migration(migrations.Migration):
operations = [
migrations.RunPython(
code=migrate_text_ckeditor_fields,
reverse_code=migrations.RunPython.noop,
)
]
53 changes: 46 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"sass": "^1.72.0",
"sass-loader": "^14.1.1",
"slim-select": "^2.8.2",
"source-map-loader": "^5.0.0",
"style-loader": "^3.3.4",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4"
Expand Down
7 changes: 6 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@ module.exports = {
{
test: /\.(s[ac]ss)$/i,
use: [MiniCssExtractPlugin.loader, 'css-loader', 'sass-loader'],
},
},
{
test: /\.js$/,
enforce: "pre",
use: ["source-map-loader"],
},

// {
// test: /\.js$/,
Expand Down

0 comments on commit 091239e

Please sign in to comment.