Skip to content

Instantly share code, notes, and snippets.

@rlskoeser
Created July 23, 2024 19:26
Show Gist options
  • Save rlskoeser/757d6a1e412f24be6f894a6e7f218a1d to your computer and use it in GitHub Desktop.
Save rlskoeser/757d6a1e412f24be6f894a6e7f218a1d to your computer and use it in GitHub Desktop.
# check_migrated_block
import csv
import os
import django
os.environ["DJANGO_SETTINGS_MODULE"] = "cdhweb.settings"
django.setup()
from cdhweb.pages.models import ContentPage, LandingPage
from cdhweb.events.models import Event
from cdhweb.projects.models import Project
from cdhweb.people.models import Profile
output = "migrated_content.csv"
csvfile = open(output, "w")
print(f"saving report to {output}")
csvwriter = csv.writer(csvfile)
csvwriter.writerow(["page_type", "url", "title"])
pagetypes = {
"event": Event,
"contentpage": ContentPage,
"landingpage": LandingPage,
"project": Project,
"profile": Profile,
}
for pagetype, cls in pagetypes.items():
print(f"checking {pagetype}")
for page in cls.objects.live():
if "migrated" in [b.block_type for b in page.body]:
csvwriter.writerow([pagetype, page.full_url, page.title])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment