Skip to content

Commit

Permalink
fix template label nested translation (#6687)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Bazik committed Sep 8, 2020
1 parent e428cb3 commit cb423f9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cms/models/pagemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class Page(models.Model):
(constants.X_FRAME_OPTIONS_ALLOW, _('Allow'))
)

template_choices = [(x, _(y)) for x, y in get_cms_setting('TEMPLATES')]
template_choices = [(x, y) for x, y in get_cms_setting('TEMPLATES')]

created_by = models.CharField(
_("created by"), max_length=constants.PAGE_USERNAME_MAX_LENGTH,
Expand Down
12 changes: 12 additions & 0 deletions cms/tests/test_no_i18n.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
from django.utils.translation import trans_null
from django.contrib.auth import get_user_model
from django.template import Template
from django.test import RequestFactory
from django.test.utils import override_settings
from django.urls import clear_url_caches

from cms.constants import TEMPLATE_INHERITANCE_MAGIC
from cms.api import create_page
from cms.middleware.toolbar import ToolbarMiddleware
from cms.models import Page, CMSPlugin
Expand All @@ -13,6 +15,8 @@
from cms.toolbar.toolbar import CMSToolbar
from cms.utils.conf import get_cms_setting

from mock import patch

overrides = dict(
LANGUAGE_CODE='en-us',
LANGUAGES=[],
Expand Down Expand Up @@ -183,3 +187,11 @@ def test_toolbar_no_locale(self):
toolbar = CMSToolbar(request)
toolbar.set_object(sub)
self.assertEqual(toolbar.get_object_public_url(), '/test/sub/')

@patch('django.utils.translation._trans', new=trans_null)
def test_inherit_label(self):
page = create_page('test', 'nav_playground.html', 'en-us', published=True)
with self.login_user_context(self.get_superuser()):
endpoint = self.get_admin_url(Page, 'advanced', page.pk)
response = self.client.get(endpoint)
self.assertContains(response, '<option value="%s">' % TEMPLATE_INHERITANCE_MAGIC)

0 comments on commit cb423f9

Please sign in to comment.