mirror of
https://github.com/daniviga/django-ram.git
synced 2025-08-04 13:17:50 +02:00
Various improvements for flatpages
This commit is contained in:
@@ -6,12 +6,12 @@ from django.db import migrations
|
||||
|
||||
def md_to_html(apps, schema_editor):
|
||||
fields = {
|
||||
'SiteConfiguration': ['about', 'footer', 'footer_extended'],
|
||||
'Flatpage': ['content']
|
||||
"SiteConfiguration": ["about", "footer", "footer_extended"],
|
||||
"Flatpage": ["content"]
|
||||
}
|
||||
|
||||
for m in fields.items():
|
||||
model = apps.get_model('portal', m[0])
|
||||
model = apps.get_model("portal", m[0])
|
||||
|
||||
for row in model.objects.all():
|
||||
for field in m[1]:
|
||||
|
@@ -0,0 +1,42 @@
|
||||
# Generated by Django 4.1 on 2022-08-25 10:18
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def reverse_bool(apps, schema_editor):
|
||||
model = apps.get_model("portal", "Flatpage")
|
||||
|
||||
for row in model.objects.all():
|
||||
row.published = not row.draft
|
||||
row.save(update_fields=["published"])
|
||||
|
||||
|
||||
def reverse_bool_back(apps, schema_editor):
|
||||
model = apps.get_model("portal", "Flatpage")
|
||||
|
||||
for row in model.objects.all():
|
||||
row.draft = not row.published
|
||||
row.save(update_fields=["draft"])
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("portal", "0012_md_to_html"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="flatpage",
|
||||
name="published",
|
||||
field=models.BooleanField(default=False),
|
||||
),
|
||||
migrations.RunPython(
|
||||
reverse_bool,
|
||||
reverse_code=reverse_bool_back
|
||||
),
|
||||
migrations.RemoveField(
|
||||
model_name="flatpage",
|
||||
name="draft",
|
||||
),
|
||||
]
|
Reference in New Issue
Block a user