Skip to content

fix: Add check for Django's i18n context processor needed for wizards to work #7699

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions cms/tests/test_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,30 @@ def test_no_sekizai(self):
with self.settings(INSTALLED_APPS=apps):
self.assertCheck(False, errors=1)

def test_no_django_i18n_context_processor(self):
override = {'TEMPLATES': deepcopy(settings.TEMPLATES)}
override['TEMPLATES'][0]['OPTIONS']['context_processors'] = [
'sekizai.context_processors.sekizai',
'cms.context_processors.cms_settings'
]
with self.settings(**override):
self.assertCheck(False, errors=1)

def test_no_cms_settings_context_processor(self):
override = {'TEMPLATES': deepcopy(settings.TEMPLATES)}
override['TEMPLATES'][0]['OPTIONS']['context_processors'] = ['sekizai.context_processors.sekizai']
override['TEMPLATES'][0]['OPTIONS']['context_processors'] = [
'sekizai.context_processors.sekizai',
'django.template.context_processors.i18n',
]
with self.settings(**override):
self.assertCheck(False, errors=1)

def test_no_sekizai_template_context_processor(self):
override = {'TEMPLATES': deepcopy(settings.TEMPLATES)}
override['TEMPLATES'][0]['OPTIONS']['context_processors'] = ['cms.context_processors.cms_settings']
override['TEMPLATES'][0]['OPTIONS']['context_processors'] = [
'cms.context_processors.cms_settings',
'django.template.context_processors.i18n',
]
with self.settings(**override):
self.assertCheck(False, errors=2)

Expand Down
8 changes: 5 additions & 3 deletions cms/utils/check.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def check_context_processors(output):
chain(*[template['OPTIONS'].get('context_processors', []) for template in settings.TEMPLATES]))
required_processors = (
'cms.context_processors.cms_settings',
'django.template.context_processors.i18n'
)
for processor in required_processors:
if processor not in processors:
Expand Down Expand Up @@ -338,9 +339,9 @@ def get_class(method_name, model):
))

if not section.warnings:
section.finish_success('All plugins and page/title extensions have "copy_relations" method if needed.')
section.finish_success('All plugins and page/page content extensions have "copy_relations" method if needed.')
else:
section.finish_success('Some plugins or page/title extensions do not define a "copy_relations" method.\n'
section.finish_success('Some plugins or page/page content extensions do not define a "copy_relations" method.\n'
'This might lead to data loss when publishing or copying plugins/extensions.\n'
'See https://django-cms.readthedocs.io/en/latest/extending_cms/custom_plugins.html#handling-relations or ' # noqa
'https://django-cms.readthedocs.io/en/latest/extending_cms/extending_page_title.html#handling-relations.') # noqa
Expand All @@ -354,7 +355,8 @@ def check(output):

Returns whether the configuration/environment are okay (has no errors)
"""
title = "Checking django CMS installation"
import cms
title = f"Checking django CMS {cms.__version__} installation"
border = '*' * len(title)
output.write_line(output.colorize(border, opts=['bold']))
output.write_line(output.colorize(title, opts=['bold']))
Expand Down