This repository has been archived by the owner on Jun 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
data migration to add raw-html-embed
- Loading branch information
1 parent
a480232
commit 954f4ff
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
geocity/apps/reports/migrations/0032_data_migration_sectionparagraph.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 4.2.1 on 2023-06-15 16:21 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
def update_sectionparagraph(apps, schema_editor): | ||
|
||
SectionParagraph = apps.get_model("reports", "SectionParagraph") | ||
html_embed_open = '<div class="raw-html-embed">' | ||
html_embed_close = "</div>" | ||
|
||
# Update sections containing "div" or "class" or "table" | ||
sections_with_keywords = ( | ||
SectionParagraph.objects.filter(content__contains="div") | ||
| SectionParagraph.objects.filter(content__contains="class") | ||
| SectionParagraph.objects.filter(content__contains="table") | ||
) | ||
|
||
for section in sections_with_keywords: | ||
section.content = f"{html_embed_open}{section.content}{html_embed_close}" | ||
section.save(update_fields=["content"]) | ||
|
||
dependencies = [ | ||
( | ||
"reports", | ||
"0031_alter_sectionrecipient_first_recipient_and_more", | ||
), | ||
] | ||
|
||
operations = [ | ||
migrations.RunPython(update_sectionparagraph), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -661,6 +661,7 @@ | |
"items": [ | ||
"undo", | ||
"redo", | ||
"htmlEmbed", | ||
"sourceEditing", | ||
"|", | ||
"heading", | ||
|