From af96faefcf62f9e8936a002566a25ebcfef5cc0f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 07:06:20 +0000 Subject: [PATCH] ci: auto fixes from pre-commit hooks for more information, see https://pre-commit.ci --- djangocms_alias/cms_toolbars.py | 4 +--- djangocms_alias/internal_search.py | 5 +---- tests/test_admin.py | 20 ++++---------------- tests/test_views.py | 25 ++++++------------------- tests/test_wizards.py | 3 --- 5 files changed, 12 insertions(+), 45 deletions(-) diff --git a/djangocms_alias/cms_toolbars.py b/djangocms_alias/cms_toolbars.py index dc8043b..7d24147 100644 --- a/djangocms_alias/cms_toolbars.py +++ b/djangocms_alias/cms_toolbars.py @@ -186,9 +186,7 @@ def override_language_switcher(self): ) if alias_content: url = get_object_edit_url(alias_content, language=code) - language_menu.add_link_item( - name, url=url, active=self.current_lang == code - ) + language_menu.add_link_item(name, url=url, active=self.current_lang == code) def change_language_menu(self): if self.toolbar.edit_mode_active and isinstance(self.toolbar.obj, AliasContent): diff --git a/djangocms_alias/internal_search.py b/djangocms_alias/internal_search.py index 9fb516d..30b02c1 100644 --- a/djangocms_alias/internal_search.py +++ b/djangocms_alias/internal_search.py @@ -1,9 +1,6 @@ -from cms.toolbar.utils import get_toolbar_from_request +from cms.toolbar.utils import get_object_preview_url, get_toolbar_from_request from django.template import RequestContext from django.utils.translation import gettext_lazy as _ - -from cms.toolbar.utils import get_object_preview_url, get_toolbar_from_request - from djangocms_internalsearch.base import BaseSearchConfig from djangocms_internalsearch.helpers import get_request, get_version_object from haystack import indexes diff --git a/tests/test_admin.py b/tests/test_admin.py index 8908e88..3125990 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -2,6 +2,7 @@ from bs4 import BeautifulSoup from cms.api import add_plugin +from cms.toolbar.utils import get_object_preview_url from cms.utils.i18n import force_language from cms.utils.urlutils import add_url_parameters, admin_reverse from django.contrib.auth.models import Permission @@ -9,13 +10,6 @@ from django.utils.formats import localize from django.utils.timezone import localtime -from cms.api import add_plugin -from cms.toolbar.utils import get_object_preview_url -from cms.utils.i18n import force_language -from cms.utils.urlutils import add_url_parameters, admin_reverse - -from bs4 import BeautifulSoup - from djangocms_alias.constants import ( CHANGE_ALIAS_URL_NAME, USAGE_ALIAS_URL_NAME, @@ -435,15 +429,9 @@ def test_aliascontent_list_view(self): self.assertNotContains(response, "Published") self.assertNotContains(response, "Draft") - aliascontent1_url = get_object_preview_url( - alias1.get_content(show_draft_content=True) - ) - aliascontent2_url = get_object_preview_url( - alias2.get_content(show_draft_content=True) - ) - aliascontent3_url = get_object_preview_url( - alias3.get_content(show_draft_content=True) - ) + aliascontent1_url = get_object_preview_url(alias1.get_content(show_draft_content=True)) + aliascontent2_url = get_object_preview_url(alias2.get_content(show_draft_content=True)) + aliascontent3_url = get_object_preview_url(alias3.get_content(show_draft_content=True)) # when versioning is not enabled, the django admin change form # is used which used links to the aliascontent_change view diff --git a/tests/test_views.py b/tests/test_views.py index aa287c2..e0c4e9f 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -893,10 +893,7 @@ def test_alias_usage_view(self): ) self.assertRegex( str(response.content), - r'href="{}"[\w+]?>{}<\/a>'.format( - re.escape(get_object_preview_url(root_alias.get_content())), - str(alias), - ), + rf'href="{re.escape(get_object_preview_url(root_alias.get_content()))}"[\w+]?>{str(alias)}<\/a>', ) self.assertRegex( str(response.content), @@ -1530,9 +1527,7 @@ def test_view_multilanguage(self): if is_versioning_enabled(): # we need to call get_absolute_url on the AliasContent object when versioning is enabled, # otherwise we are taken to the version list url - detail_response = self.client.get( - get_object_edit_url(alias.get_content(language="en")) - ) + detail_response = self.client.get(get_object_edit_url(alias.get_content(language="en"))) else: detail_response = self.client.get(alias.get_absolute_url()) list_response = self.client.get( @@ -1550,13 +1545,9 @@ def test_view_multilanguage(self): if is_versioning_enabled(): # we need to call get_absolute_url on the AliasContent object when versioning is enabled, # otherwise we are taken to the version list url - detail_response = self.client.get( - get_object_edit_url(alias_content_de) - ) + detail_response = self.client.get(get_object_edit_url(alias_content_de)) else: - detail_response = self.client.get( - get_object_edit_url(alias.get_content()) - ) + detail_response = self.client.get(get_object_edit_url(alias.get_content())) list_response = self.client.get( admin_reverse(LIST_ALIAS_URL_NAME), ) @@ -1572,13 +1563,9 @@ def test_view_multilanguage(self): if is_versioning_enabled(): # we need to call get_absolute_url on the AliasContent object when versioning is enabled, # otherwise we are taken to the version list url - detail_response = self.client.get( - get_object_edit_url(alias_content_fr) - ) + detail_response = self.client.get(get_object_edit_url(alias_content_fr)) else: - detail_response = self.client.get( - get_object_edit_url(alias.get_content()) - ) + detail_response = self.client.get(get_object_edit_url(alias.get_content())) list_response = self.client.get( admin_reverse(LIST_ALIAS_URL_NAME), # noqa: E501 ) diff --git a/tests/test_wizards.py b/tests/test_wizards.py index a78e976..cf69265 100644 --- a/tests/test_wizards.py +++ b/tests/test_wizards.py @@ -1,6 +1,3 @@ -from django.contrib.sites.models import Site -from django.utils import translation - from cms.toolbar.utils import get_object_edit_url from cms.utils import get_current_site from cms.wizards.forms import WizardStep2BaseForm, step2_form_factory