Skip to content

Commit

Permalink
Fix: Workaround for newer versioning versions potentially used with d…
Browse files Browse the repository at this point in the history
…jangocms-url-manager
  • Loading branch information
fsbraun committed Jun 20, 2024
1 parent 3407419 commit 19779c3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
9 changes: 7 additions & 2 deletions djangocms_frontend/contrib/link/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,17 @@ def get_link(self):
url_grouper = get_related_object(self.config, "url_grouper")
if not url_grouper:
return ""
url = url_grouper.get_content(show_draft_content=True)
# The next line is a workaround, since djangocms-url-manager does not provide a way of
# getting the current URL object.
from djangocms_url_manager.models import Url
url = Url._base_manager.filter(url_grouper=url_grouper).order_by("pk").last()
if not url:
return ""

Check warning on line 25 in djangocms_frontend/contrib/link/models.py

View check run for this annotation

Codecov / codecov/patch

djangocms_frontend/contrib/link/models.py#L25

Added line #L25 was not covered by tests
# simulate the call to the unauthorized CMSPlugin.page property
cms_page = self.placeholder.page if self.placeholder_id else None

# first, we check if the placeholder the plugin is attached to
# has a page. Thus the check "is not None":
# has a page. Thus, the check "is not None":
if cms_page is not None:
if getattr(cms_page, "node", None):
cms_page_site_id = getattr(cms_page.node, "site_id", None)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_plugin_tag.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from unittest import skipIf

from cms import __version__ as cms_version
from cms.test_utils.testcases import CMSTestCase
from django.contrib.sites.shortcuts import get_current_site
Expand Down Expand Up @@ -78,7 +76,6 @@ def test_complex_tags(self):

self.assertInHTML(expected_result, result)

@skipIf(cms_version < "4", "djangocms-url-manager currently does not work with django CMS 4.1+")
def test_link_plugin(self):
if cms_version < "4":
grouper = None
Expand Down

0 comments on commit 19779c3

Please sign in to comment.