Skip to content

Commit

Permalink
ci: auto fixes from pre-commit hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Mar 5, 2024
1 parent ef5760e commit af96fae
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 45 deletions.
4 changes: 1 addition & 3 deletions djangocms_alias/cms_toolbars.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
5 changes: 1 addition & 4 deletions djangocms_alias/internal_search.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 4 additions & 16 deletions tests/test_admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,14 @@

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
from django.urls import reverse
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,
Expand Down Expand Up @@ -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
Expand Down
25 changes: 6 additions & 19 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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(
Expand All @@ -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),
)
Expand All @@ -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
)
Expand Down
3 changes: 0 additions & 3 deletions tests/test_wizards.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit af96fae

Please sign in to comment.