mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 05:07:50 +02:00
Add migrations md to html
This commit is contained in:
34
ram/consist/migrations/0006_md_to_html.py
Normal file
34
ram/consist/migrations/0006_md_to_html.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 4.1 on 2022-08-24 15:30
|
||||
|
||||
import markdown
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def md_to_html(apps, schema_editor):
|
||||
fields = {
|
||||
'Consist': ['notes'],
|
||||
}
|
||||
|
||||
for m in fields.items():
|
||||
model = apps.get_model('consist', m[0])
|
||||
|
||||
for row in model.objects.all():
|
||||
for field in m[1]:
|
||||
field = getattr(row, field)
|
||||
field = markdown.markdown(field)
|
||||
|
||||
row.save(update_fields=m[1])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("consist", "0005_alter_consist_notes"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
md_to_html,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
38
ram/portal/migrations/0012_md_to_html.py
Normal file
38
ram/portal/migrations/0012_md_to_html.py
Normal file
@@ -0,0 +1,38 @@
|
||||
# Generated by Django 4.1 on 2022-08-24 15:00
|
||||
|
||||
import markdown
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def md_to_html(apps, schema_editor):
|
||||
fields = {
|
||||
'SiteConfiguration': ['about', 'footer', 'footer_extended'],
|
||||
'Flatpage': ['content']
|
||||
}
|
||||
|
||||
for m in fields.items():
|
||||
model = apps.get_model('portal', m[0])
|
||||
|
||||
for row in model.objects.all():
|
||||
for field in m[1]:
|
||||
field = getattr(row, field)
|
||||
field = markdown.markdown(field)
|
||||
|
||||
row.save(update_fields=m[1])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
(
|
||||
"portal",
|
||||
"0011_alter_flatpage_content_alter_siteconfiguration_about_and_more",
|
||||
),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
md_to_html,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
34
ram/roster/migrations/0011_md_to_html.py
Normal file
34
ram/roster/migrations/0011_md_to_html.py
Normal file
@@ -0,0 +1,34 @@
|
||||
# Generated by Django 4.1 on 2022-08-24 15:30
|
||||
|
||||
import markdown
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def md_to_html(apps, schema_editor):
|
||||
fields = {
|
||||
'RollingStock': ['notes'],
|
||||
}
|
||||
|
||||
for m in fields.items():
|
||||
model = apps.get_model('roster', m[0])
|
||||
|
||||
for row in model.objects.all():
|
||||
for field in m[1]:
|
||||
field = getattr(row, field)
|
||||
field = markdown.markdown(field)
|
||||
|
||||
row.save(update_fields=m[1])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("roster", "0010_alter_rollingstock_notes"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(
|
||||
md_to_html,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user