Skip to content

Commit

Permalink
🚧 create migrations for CMS 4
Browse files Browse the repository at this point in the history
  • Loading branch information
Coperh committed Nov 6, 2024
1 parent 1fc962d commit 8e32724
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
7 changes: 5 additions & 2 deletions djangocms_page_meta/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
from cms.admin.pageadmin import PageAdmin
from cms.extensions import PageExtensionAdmin, TitleExtensionAdmin
try:
from cms.extensions import PageExtensionAdmin, PageContentExtensionAdmin
except ImportError:
from cms.extensions import PageExtensionAdmin, TitleExtensionAdmin as PageContentExtensionAdmin
from cms.utils import get_language_from_request
from django.conf import settings
from django.contrib import admin
Expand Down Expand Up @@ -68,7 +71,7 @@ def get_model_perms(self, request):


@admin.register(TitleMeta)
class TitleMetaAdmin(TitleExtensionAdmin):
class TitleMetaAdmin(PageContentExtensionAdmin):
form = TitleMetaAdminForm
inlines = (GenericAttributeTitleInline,)

Expand Down
3 changes: 3 additions & 0 deletions djangocms_page_meta/migrations/0016_auto_20230830_1007.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ class Migration(migrations.Migration):
dependencies = [
("djangocms_page_meta", "0015_defaultmetaimage"),
]
run_before = [
("cms", "0032_remove_title_to_pagecontent"),
]

operations = [
migrations.RunPython(generate_default_meta_image_singleton, backwards),
Expand Down
15 changes: 11 additions & 4 deletions djangocms_page_meta/models.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
import ast

from cms.extensions import PageExtension, TitleExtension
try:
from cms.models import Page, PageContent
from cms.extensions import PageExtension, PageContentExtension
except ImportError:
from cms.extensions import PageExtension, TitleExtension as PageContentExtension
from cms.models import Page, Title as PageContent


from cms.extensions.extension_pool import extension_pool
from cms.models import Page, Title

from django.conf import settings
from django.core.cache import cache
from django.db import models
Expand Down Expand Up @@ -98,7 +105,7 @@ def robots_list(self):
extension_pool.register(PageMeta)


class TitleMeta(TitleExtension):
class TitleMeta(PageContentExtension):
image = FilerFileField(
null=True,
blank=True,
Expand Down Expand Up @@ -206,7 +213,7 @@ def cleanup_page(sender, instance, **kwargs):
cache.delete(key)


@receiver(pre_delete, sender=Title)
@receiver(pre_delete, sender=PageContent)
def cleanup_title(sender, instance, **kwargs):
key = get_cache_key(instance.page, instance.language)
cache.delete(key)
Expand Down

0 comments on commit 8e32724

Please sign in to comment.