Skip to content
This repository has been archived by the owner on Jun 24, 2024. It is now read-only.

Commit

Permalink
data migration to add raw-html-embed
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreJunod committed Mar 11, 2024
1 parent a480232 commit 954f4ff
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
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),
]
1 change: 1 addition & 0 deletions geocity/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,7 @@
"items": [
"undo",
"redo",
"htmlEmbed",
"sourceEditing",
"|",
"heading",
Expand Down

0 comments on commit 954f4ff

Please sign in to comment.