Skip to content

Commit

Permalink
fix: get_page_content retrieved non page-content objects from the too…
Browse files Browse the repository at this point in the history
…lbar
  • Loading branch information
fsbraun authored Sep 20, 2024
1 parent ac763d9 commit 9004d0e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions djangocms_versioning/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,16 +295,18 @@ def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)

def get_page_content(self, language: Optional[str] = None) -> PageContent:
# This method overwrites the method in django CMS core. Not necessary

Check failure on line 298 in djangocms_versioning/cms_toolbars.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W291)

djangocms_versioning/cms_toolbars.py:298:78: W291 Trailing whitespace

Check failure on line 298 in djangocms_versioning/cms_toolbars.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W291)

djangocms_versioning/cms_toolbars.py:298:78: W291 Trailing whitespace
# for django CMS 4.2+
if not language:
language = self.current_lang

if self.page_content and self.page_content.language == language:
# Already known - no need to query it again
return self.page_content
toolbar_obj = self.toolbar.get_object()
if toolbar_obj and toolbar_obj.language == language:
if isinstance(toolbar_obj, PageContent) and toolbar_obj.language == language:
# Already in the toolbar, then use it!
return self.toolbar.get_object()
return toolbar_obj
else:
# Get it from the DB
return get_latest_admin_viewable_content(self.page, language=language)
Expand Down

0 comments on commit 9004d0e

Please sign in to comment.