migrate djac to Django cms 4
on January 1st 2024 django-cms 4.1 has been released as the first community-based version. this MR implements the logic.
unfortunately not everything is working yet. We need to implement the fix in https://github.com/django-cms/djangocms-link/pull/201 (which is ok via pipenv install git+https://github.com/Aiky30/djangocms-link.git@feature/support-cms-4_0#egg=djangocms_link
).
Furthermore, the migration needs to be prepared with the following commands:
from academic_community import models
from cms.models import Page, PagePermission
for link in models.InternalLink.objects.filter(
config__internal_link__model="cms.page"
):
page = Page.objects.get(pk=link.internal_link["pk"])
if page.publisher_is_draft:
link.config["internal_link"]["pk"] = page.publisher_public.pk
link.save()
for perm in PagePermission.objects.filter(page__publisher_is_draft=True):
perm.page = perm.page.publisher_public
perm.save()
for menu in models.MenuPluginModel.objects.filter(
root_id__publisher_is_draft=True
):
menu.root_id = menu.root_id.publisher_public
menu.save()
models.PageMenuExtension.objects.filter(
extended_object__publisher_is_draft=True
).delete()
models.PageStylesExtension.objects.filter(
extended_object__publisher_is_draft=True
).delete()
and (at least for the CLM-Community, but this is probably an artifact from the migration) we have some duplicated plugins that share the same position (identified via
# SELECT * FROM cms_cmsplugin INNER JOIN (SELECT placeholder_id, position, COUNT(*) FROM cms_cmsplugin GROUP BY placeholder_id, position HAVING COUNT(*) > 1) as foo USING (placeholder_id, position) INNER JOIN (SELECT * FROM cms_page_placeholders INNER JOIN cms_title USING (page_id)) as foo2 USING (placeholder_id) INNER JOIN academic_community_internalnamebootstrap5link ON cms_cmsplugin.id=cmsplugin_ptr_id ORDER BY placeholder_id;`
). These instances of InternalNameBootstrap5Link
need to be deleted prior to the migration via
from academic_community import models
models.InternalLink.objects.filter(pk__in=pks).delete()