diff --git a/CHANGELOG.rst b/CHANGELOG.rst index b350088a..d95fe481 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,7 @@ Changelog Unreleased ========== +* fix: Only try modifying page language menu if it is present * fix: Added ``related_name`` attribute to the ``content_type`` foreign key of the ``Version`` model. * fix: burger menu adjusts to the design of django cms core dropdown * fix: bug that showed an archived version as unpublished in some cases in the state indicator diff --git a/MANIFEST.in b/MANIFEST.in index 2972e242..5189771b 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -2,4 +2,5 @@ include LICENSE.txt include README.rst recursive-include djangocms_versioning/static * recursive-include djangocms_versioning/templates * +recursive-include djangocms_versioning/locale * recursive-exclude * *.pyc diff --git a/djangocms_versioning/cms_toolbars.py b/djangocms_versioning/cms_toolbars.py index a2f16930..5ac50365 100644 --- a/djangocms_versioning/cms_toolbars.py +++ b/djangocms_versioning/cms_toolbars.py @@ -320,10 +320,9 @@ def override_language_menu(self): Override the default language menu for pages that are versioned. The default language menu is too generic so for pages we need to replace it. """ - # Only override the menu if a page can be found - if settings.USE_I18N and self.page: - language_menu = self.toolbar.get_menu(LANGUAGE_MENU_IDENTIFIER, _("Language")) - + # Only override the menu if it exists and a page can be found + language_menu = self.toolbar.get_menu(LANGUAGE_MENU_IDENTIFIER, _("Language")) + if settings.USE_I18N and language_menu and self.page: # remove_item uses `items` attribute so we have to copy object for _item in copy(language_menu.items): language_menu.remove_item(item=_item) diff --git a/djangocms_versioning/locale/de/LC_MESSAGES/django.mo b/djangocms_versioning/locale/de/LC_MESSAGES/django.mo index 51edfdce..27db87fb 100644 Binary files a/djangocms_versioning/locale/de/LC_MESSAGES/django.mo and b/djangocms_versioning/locale/de/LC_MESSAGES/django.mo differ diff --git a/djangocms_versioning/locale/nl/LC_MESSAGES/django.mo b/djangocms_versioning/locale/nl/LC_MESSAGES/django.mo index 0238b9ad..a1ffd899 100644 Binary files a/djangocms_versioning/locale/nl/LC_MESSAGES/django.mo and b/djangocms_versioning/locale/nl/LC_MESSAGES/django.mo differ diff --git a/djangocms_versioning/locale/nl/LC_MESSAGES/django.po b/djangocms_versioning/locale/nl/LC_MESSAGES/django.po index 36a464a4..fec58ac3 100644 --- a/djangocms_versioning/locale/nl/LC_MESSAGES/django.po +++ b/djangocms_versioning/locale/nl/LC_MESSAGES/django.po @@ -266,7 +266,7 @@ msgstr "Actie niet geldig. De laatste versie is gesloten door {user}" #: models.py:33 #, python-brace-format msgid "Action Denied. The draft version is locked by {user}" -msgstr "Actie niet geldig. De concept versie is gesloten door " +msgstr "Actie niet geldig. De concept versie is gesloten door {user}" #: models.py:88 msgid "Created" diff --git a/tests/test_toolbars.py b/tests/test_toolbars.py index c7b77e3b..8142d22f 100644 --- a/tests/test_toolbars.py +++ b/tests/test_toolbars.py @@ -578,3 +578,27 @@ def test_change_language_menu_page_toolbar_language_selector_version_link(self): self.assertEqual(en_item.url, en_preview_url) self.assertEqual(de_item.url, de_preview_url) self.assertEqual(it_item.url, it_preview_url) + + def test_page_toolbar_wo_language_menu(self): + from django.utils.translation import gettext as _ + + pagecontent = PageContentWithVersionFactory(language="en") + page = pagecontent.page + # Get request + request = self.get_page_request( + page=page, + path=get_object_edit_url(pagecontent), + user=self.get_superuser(), + ) + # Remove language menu from request's toolbar + del request.toolbar.menus[LANGUAGE_MENU_IDENTIFIER] + + # find VersioningPageToolbar + for cls, toolbar in request.toolbar.toolbars.items(): + if cls == "djangocms_versioning.cms_toolbars.VersioningPageToolbar": + # and call override_language_menu + toolbar.override_language_menu() + break + + language_menu = request.toolbar.get_menu(LANGUAGE_MENU_IDENTIFIER, _("Language")) + self.assertIsNone(language_menu)