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 96d9a2d
Show file tree
Hide file tree
Showing 3 changed files with 36 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Generated by Django 4.2.16 on 2024-11-06 20:52

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):

dependencies = [
('cms', '0037_alter_cmsplugin_id_alter_globalpagepermission_id_and_more'),
('djangocms_page_meta', '0016_auto_20230830_1007'),
]

operations = [
migrations.AlterField(
model_name='titlemeta',
name='extended_object',
field=models.OneToOneField(editable=False, on_delete=django.db.models.deletion.CASCADE, to='cms.pagecontent'),
),
]
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 96d9a2d

Please sign in to comment.