Skip to content

Commit

Permalink
fix import sort issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
FreemanPancake committed Oct 30, 2024
1 parent 5e14400 commit f484d7f
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 17 deletions.
5 changes: 2 additions & 3 deletions djangocms_navigation/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from djangocms_versioning.models import Version
from treebeard.admin import TreeAdmin

from .compat import TREEBEARD_4_5
from .compat import CMS_41, TREEBEARD_4_5
from .conf import TREE_MAX_RESULT_PER_PAGE_COUNT
from .filters import LanguageFilter
from .forms import MenuContentForm, MenuItemForm
Expand All @@ -36,14 +36,13 @@
from .utils import is_versioning_enabled, purge_menu_cache, reverse_admin_name
from .views import ContentObjectSelect2View, MessageStorageView

from .compat import CMS_41


menuitem_admin_class = [TreeAdmin]

try:
if CMS_41:
from cms.admin.utils import ChangeListActionsMixin

from djangocms_versioning.helpers import (
content_is_unlocked_for_user,
version_is_locked,
Expand Down
4 changes: 2 additions & 2 deletions djangocms_navigation/compat.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from cms import __version__ as CMS_VERSION

from packaging.version import Version
from treebeard import __version__ as treebeard_version

from cms import __version__ as CMS_VERSION


TREEBEARD_4_5 = Version(treebeard_version) < Version('4.6')
CMS_41 = Version("4.1") <= Version(CMS_VERSION)
2 changes: 1 addition & 1 deletion djangocms_navigation/test_utils/factories.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class PageContentWithVersionFactory(PageContentFactory):
def version(self, create, extracted, **kwargs):
# NOTE: Use this method as below to define version attributes:
# PageContentWithVersionFactory(version__label='label1')

if not create:
# Simple build, do nothing.
return
Expand Down
2 changes: 1 addition & 1 deletion djangocms_navigation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def get_latest_page_content_for_page_grouper(obj, language):
:return: A queryset if an item exists, or None if not.
:rtype: Queryset object, or None
"""
if CMS_41:
if CMS_41:
page_contents = PageContent.admin_manager.filter(
page=obj,
language=language,
Expand Down
5 changes: 3 additions & 2 deletions djangocms_navigation/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
from cms.models import Page
from cms.utils import get_current_site, get_language_from_request

from djangocms_navigation.utils import is_model_supported, supported_models
from djangocms_navigation.compat import CMS_41
from djangocms_versioning.constants import ARCHIVED, UNPUBLISHED

from djangocms_navigation.compat import CMS_41
from djangocms_navigation.utils import is_model_supported, supported_models


class ContentObjectSelect2View(View):
menu_content_model = None
Expand Down
8 changes: 3 additions & 5 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,9 @@
import importlib
import json
import sys

from bs4 import BeautifulSoup
from unittest import skipIf, skipUnless
from unittest.mock import patch


from django.contrib import admin
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
Expand All @@ -23,6 +20,7 @@
from cms.toolbar.utils import get_object_preview_url
from cms.utils.compat import DJANGO_4_1

from bs4 import BeautifulSoup
from djangocms_versioning.constants import DRAFT, PUBLISHED, UNPUBLISHED
from djangocms_versioning.exceptions import ConditionFailed
from djangocms_versioning.helpers import version_list_url
Expand All @@ -33,13 +31,13 @@
MenuItemAdmin,
MenuItemChangeList,
)
from djangocms_navigation.compat import TREEBEARD_4_5
from djangocms_navigation.compat import CMS_41, TREEBEARD_4_5
from djangocms_navigation.models import Menu, MenuContent, MenuItem
from djangocms_navigation.test_utils import factories

from djangocms_navigation.compat import CMS_41
from .utils import UsefulAssertsMixin, disable_versioning_for_navigation


versioning_substr = ""
if CMS_41:
from cms.api import create_page_content # noqa: F401
Expand Down
1 change: 0 additions & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
UNPUBLISHED,
)

from djangocms_navigation.compat import CMS_41
from djangocms_navigation.models import MenuContent
from djangocms_navigation.test_utils import factories
from djangocms_navigation.test_utils.app_1.models import TestModel1, TestModel2
Expand Down
14 changes: 12 additions & 2 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,13 @@ def test_with_pages_for_multiple_sites(self):
site1 = Site.objects.create(name="site1.com", domain="site1.com")
site2 = Site.objects.create(name="site2.com", domain="site2.com")
PageContentFactory.create_batch(10, title="test", page__node__site=site1, language="en")
expected = PageContentWithVersionFactory(title="test", menu_title="site2 page", page__node__site=site2, language="en", version__state=PUBLISHED)
expected = PageContentWithVersionFactory(
title="test",
menu_title="site2 page",
page__node__site=site2,
language="en",
version__state=PUBLISHED
)

with self.login_user_context(self.superuser):
response = self.client.get(
Expand Down Expand Up @@ -350,7 +356,11 @@ def test_searching_for_page_path(self):
page_contenttype_id = ContentType.objects.get_for_model(Page).id
PageContentFactory.create_batch(10, language="en")
expected = PageContentWithVersionFactory(
title="test", menu_title="Test search by overwritten url", page_title="test", language="en", version__state=PUBLISHED
title="test",
menu_title="Test search by overwritten url",
page_title="test",
language="en",
version__state=PUBLISHED
)
# update page urls to use a randomly generated path to represent setting an overwritten url
path = fake.uri_path()
Expand Down

0 comments on commit f484d7f

Please sign in to comment.