diff --git a/djangocms_alias/admin.py b/djangocms_alias/admin.py index cd653b5..d605187 100644 --- a/djangocms_alias/admin.py +++ b/djangocms_alias/admin.py @@ -1,3 +1,6 @@ +from cms.admin.utils import GrouperModelAdmin +from cms.utils.permissions import get_model_permission_codename +from cms.utils.urlutils import admin_reverse from django import forms from django.contrib import admin from django.http import ( @@ -8,11 +11,6 @@ ) from django.utils.safestring import mark_safe from django.utils.translation import gettext_lazy as _ - -from cms.admin.utils import GrouperModelAdmin -from cms.utils.permissions import get_model_permission_codename -from cms.utils.urlutils import admin_reverse - from parler.admin import TranslatableAdmin from .cms_config import AliasCMSConfig @@ -32,7 +30,6 @@ is_versioning_enabled, ) - __all__ = [ "AliasAdmin", "CategoryAdmin", diff --git a/djangocms_alias/cms_config.py b/djangocms_alias/cms_config.py index 463b4d3..573057d 100644 --- a/djangocms_alias/cms_config.py +++ b/djangocms_alias/cms_config.py @@ -1,12 +1,10 @@ +from cms.app_base import CMSAppConfig from django.apps import apps from django.conf import settings -from cms.app_base import CMSAppConfig - from .models import AliasContent, AliasPlugin, copy_alias_content from .rendering import render_alias_content - try: apps.get_app_config("djangocms_internalsearch") from .internal_search import AliasContentConfig @@ -31,7 +29,6 @@ class AliasCMSConfig(CMSAppConfig): if djangocms_versioning_enabled: from cms.utils.i18n import get_language_tuple - from djangocms_versioning.datastructures import VersionableItem versioning = [ diff --git a/djangocms_alias/cms_plugins.py b/djangocms_alias/cms_plugins.py index a426f35..6214209 100644 --- a/djangocms_alias/cms_plugins.py +++ b/djangocms_alias/cms_plugins.py @@ -1,10 +1,5 @@ from copy import copy -from django.utils.translation import ( - get_language_from_request, - gettext_lazy as _, -) - from cms.plugin_base import CMSPluginBase, PluginMenuItem from cms.plugin_pool import plugin_pool from cms.utils.permissions import ( @@ -13,11 +8,17 @@ ) from cms.utils.plugins import copy_plugins_to_placeholder from cms.utils.urlutils import add_url_parameters, admin_reverse +from django.utils.translation import ( + get_language_from_request, +) +from django.utils.translation import ( + gettext_lazy as _, +) from .constants import CREATE_ALIAS_URL_NAME, DETACH_ALIAS_PLUGIN_URL_NAME from .forms import AliasPluginForm -from .models import Alias as AliasModel, AliasContent, AliasPlugin - +from .models import Alias as AliasModel +from .models import AliasContent, AliasPlugin __all__ = [ "Alias", diff --git a/djangocms_alias/cms_toolbars.py b/djangocms_alias/cms_toolbars.py index 13bf914..4c42b6f 100644 --- a/djangocms_alias/cms_toolbars.py +++ b/djangocms_alias/cms_toolbars.py @@ -1,15 +1,6 @@ import itertools from copy import copy -from django.urls import NoReverseMatch -from django.utils.encoding import force_str -from django.utils.http import urlencode -from django.utils.translation import ( - get_language_from_request, - gettext, - gettext_lazy as _, -) - from cms.cms_toolbars import ( ADMIN_MENU_IDENTIFIER, ADMINISTRATION_BREAK, @@ -27,6 +18,16 @@ ) from cms.utils.permissions import get_model_permission_codename from cms.utils.urlutils import add_url_parameters, admin_reverse +from django.urls import NoReverseMatch +from django.utils.encoding import force_str +from django.utils.http import urlencode +from django.utils.translation import ( + get_language_from_request, + gettext, +) +from django.utils.translation import ( + gettext_lazy as _, +) from .constants import ( DELETE_ALIAS_URL_NAME, @@ -36,7 +37,6 @@ from .models import Alias, AliasContent from .utils import is_versioning_enabled - __all__ = [ "AliasToolbar", ] diff --git a/djangocms_alias/cms_wizards.py b/djangocms_alias/cms_wizards.py index 45573b6..bf75516 100644 --- a/djangocms_alias/cms_wizards.py +++ b/djangocms_alias/cms_wizards.py @@ -1,12 +1,12 @@ -from django.utils.translation import gettext_lazy as _ - from cms.utils.permissions import get_model_permission_codename from cms.wizards.wizard_base import Wizard from cms.wizards.wizard_pool import wizard_pool +from django.utils.translation import gettext_lazy as _ from .cms_plugins import Alias from .forms import CreateAliasWizardForm, CreateCategoryWizardForm -from .models import Alias as AliasModel, Category +from .models import Alias as AliasModel +from .models import Category class CreateAliasWizard(Wizard): diff --git a/djangocms_alias/compat.py b/djangocms_alias/compat.py index c4168af..96e705f 100644 --- a/djangocms_alias/compat.py +++ b/djangocms_alias/compat.py @@ -2,5 +2,4 @@ import django - DJANGO_GTE_21 = LooseVersion(django.get_version()) >= LooseVersion("2.1") diff --git a/djangocms_alias/filters.py b/djangocms_alias/filters.py index 9ed8da6..eab9bfc 100644 --- a/djangocms_alias/filters.py +++ b/djangocms_alias/filters.py @@ -1,8 +1,8 @@ +from cms.forms.utils import get_sites from django.contrib import admin from django.utils.encoding import smart_str -from django.utils.translation import get_language, gettext_lazy as _ - -from cms.forms.utils import get_sites +from django.utils.translation import get_language +from django.utils.translation import gettext_lazy as _ from .cms_config import AliasCMSConfig from .constants import ( @@ -12,7 +12,6 @@ ) from .models import Category - djangocms_versioning_enabled = AliasCMSConfig.djangocms_versioning_enabled diff --git a/djangocms_alias/forms.py b/djangocms_alias/forms.py index 31c0047..d8e1ae4 100644 --- a/djangocms_alias/forms.py +++ b/djangocms_alias/forms.py @@ -1,3 +1,10 @@ +from cms.models import CMSPlugin, Placeholder +from cms.utils import get_current_site +from cms.utils.permissions import ( + get_model_permission_codename, + has_plugin_permission, +) +from cms.utils.urlutils import admin_reverse from django import forms from django.contrib import admin from django.contrib.admin.widgets import ( @@ -7,28 +14,20 @@ from django.contrib.sites.models import Site from django.db import transaction from django.utils.translation import gettext_lazy as _ - -from cms.models import CMSPlugin, Placeholder -from cms.utils import get_current_site -from cms.utils.permissions import ( - get_model_permission_codename, - has_plugin_permission, -) -from cms.utils.urlutils import admin_reverse - from parler.forms import TranslatableModelForm from .constants import CATEGORY_SELECT2_URL_NAME, SELECT2_ALIAS_URL_NAME from .models import ( Alias, - Alias as AliasModel, AliasContent, AliasPlugin, Category, ) +from .models import ( + Alias as AliasModel, +) from .utils import emit_content_change, is_versioning_enabled - __all__ = [ "AliasPluginForm", "BaseCreateAliasForm", diff --git a/djangocms_alias/internal_search.py b/djangocms_alias/internal_search.py index f7bfdce..34d4d83 100644 --- a/djangocms_alias/internal_search.py +++ b/djangocms_alias/internal_search.py @@ -1,8 +1,6 @@ +from cms.toolbar.utils import get_toolbar_from_request from django.template import RequestContext from django.utils.translation import gettext_lazy as _ - -from cms.toolbar.utils import 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/djangocms_alias/migrations/0001_initial.py b/djangocms_alias/migrations/0001_initial.py index a8b484d..6111d96 100644 --- a/djangocms_alias/migrations/0001_initial.py +++ b/djangocms_alias/migrations/0001_initial.py @@ -1,12 +1,12 @@ # Generated by Django 2.1.1 on 2018-09-07 11:12 import cms.utils.i18n -from django.db import migrations, models -from django.conf import settings import django.db.models.deletion import parler.models +from django.conf import settings +from django.db import migrations, models -from djangocms_alias.models import get_templates, TEMPLATE_DEFAULT +from djangocms_alias.models import TEMPLATE_DEFAULT, get_templates class Migration(migrations.Migration): diff --git a/djangocms_alias/migrations/0002_auto_20200723_1424.py b/djangocms_alias/migrations/0002_auto_20200723_1424.py index dbc91d2..3e7865e 100644 --- a/djangocms_alias/migrations/0002_auto_20200723_1424.py +++ b/djangocms_alias/migrations/0002_auto_20200723_1424.py @@ -1,8 +1,8 @@ # Generated by Django 2.2.13 on 2020-07-23 14:24 -from django.db import migrations, models import django.db.models.deletion import parler.fields +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/djangocms_alias/migrations/0003_auto_20230725_1547.py b/djangocms_alias/migrations/0003_auto_20230725_1547.py index 872e77d..156d655 100644 --- a/djangocms_alias/migrations/0003_auto_20230725_1547.py +++ b/djangocms_alias/migrations/0003_auto_20230725_1547.py @@ -1,7 +1,7 @@ # Generated by Django 4.1.8 on 2023-07-25 15:47 -from django.db import migrations, models import django.db.models.deletion +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/djangocms_alias/migrations/0004_alter_aliascontent_language.py b/djangocms_alias/migrations/0004_alter_aliascontent_language.py index 0fdd5bf..21b2f2f 100644 --- a/djangocms_alias/migrations/0004_alter_aliascontent_language.py +++ b/djangocms_alias/migrations/0004_alter_aliascontent_language.py @@ -1,7 +1,7 @@ # Generated by Django 3.2.20 on 2023-07-26 13:43 -from django.db import migrations, models import django.utils.translation +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/djangocms_alias/models.py b/djangocms_alias/models.py index 183f2ee..76c20f1 100644 --- a/djangocms_alias/models.py +++ b/djangocms_alias/models.py @@ -1,14 +1,6 @@ import operator from collections import defaultdict -from django.conf import settings -from django.contrib.sites.models import Site -from django.db import models, transaction -from django.db.models import F, Q -from django.utils.encoding import force_str -from django.utils.functional import cached_property -from django.utils.translation import get_language, gettext_lazy as _ - from cms.api import add_plugin from cms.models import CMSPlugin, Placeholder from cms.models.fields import PlaceholderRelationField @@ -16,13 +8,19 @@ from cms.toolbar.utils import get_object_preview_url from cms.utils.plugins import copy_plugins_to_placeholder from cms.utils.urlutils import admin_reverse - +from django.conf import settings +from django.contrib.sites.models import Site +from django.db import models, transaction +from django.db.models import F, Q +from django.utils.encoding import force_str +from django.utils.functional import cached_property +from django.utils.translation import get_language +from django.utils.translation import gettext_lazy as _ from parler.models import TranslatableModel, TranslatedFields from .constants import CHANGE_CATEGORY_URL_NAME from .utils import is_versioning_enabled - __all__ = [ "Category", "Alias", diff --git a/djangocms_alias/templatetags/djangocms_alias_tags.py b/djangocms_alias/templatetags/djangocms_alias_tags.py index 1d1f036..b6f5c98 100644 --- a/djangocms_alias/templatetags/djangocms_alias_tags.py +++ b/djangocms_alias/templatetags/djangocms_alias_tags.py @@ -1,17 +1,15 @@ from collections import ChainMap -from django import template -from django.utils.translation import get_language - +from classytags.arguments import Argument, MultiValueArgument +from classytags.core import Tag from cms.templatetags.cms_tags import PlaceholderOptions from cms.toolbar.utils import get_toolbar_from_request from cms.utils import get_current_site, get_language_from_request from cms.utils.i18n import get_default_language, get_language_list from cms.utils.placeholder import validate_placeholder_name from cms.utils.urlutils import add_url_parameters, admin_reverse - -from classytags.arguments import Argument, MultiValueArgument -from classytags.core import Tag +from django import template +from django.utils.translation import get_language from ..constants import ( DEFAULT_STATIC_ALIAS_CATEGORY_NAME, @@ -20,7 +18,6 @@ from ..models import Alias, AliasContent, Category from ..utils import is_versioning_enabled - register = template.Library() diff --git a/djangocms_alias/test_utils/text/models.py b/djangocms_alias/test_utils/text/models.py index dedc922..86048a0 100644 --- a/djangocms_alias/test_utils/text/models.py +++ b/djangocms_alias/test_utils/text/models.py @@ -1,6 +1,5 @@ -from django.db import models - from cms.models import CMSPlugin +from django.db import models class Text(CMSPlugin): diff --git a/djangocms_alias/urls.py b/djangocms_alias/urls.py index 28c5d6d..9fb1058 100644 --- a/djangocms_alias/urls.py +++ b/djangocms_alias/urls.py @@ -1,6 +1,5 @@ from django.urls import path - from . import constants, views # isort:skip diff --git a/djangocms_alias/views.py b/djangocms_alias/views.py index 0928ade..805cc47 100644 --- a/djangocms_alias/views.py +++ b/djangocms_alias/views.py @@ -1,5 +1,7 @@ import json +from cms.models import Page +from cms.toolbar.utils import get_plugin_toolbar_info, get_plugin_tree_as_json from django.contrib import admin from django.core.exceptions import PermissionDenied from django.db.models import Q @@ -9,19 +11,18 @@ from django.utils.translation import ( get_language, get_language_from_request, +) +from django.utils.translation import ( gettext_lazy as _, ) from django.views.generic import ListView -from cms.models import Page -from cms.toolbar.utils import get_plugin_toolbar_info, get_plugin_tree_as_json - from .cms_plugins import Alias from .forms import BaseCreateAliasForm, CreateAliasForm -from .models import Alias as AliasModel, AliasPlugin, Category +from .models import Alias as AliasModel +from .models import AliasPlugin, Category from .utils import emit_content_change - JAVASCRIPT_SUCCESS_RESPONSE = """
diff --git a/setup.py b/setup.py index a545cae..5fcc3e1 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,6 @@ import djangocms_alias - CLASSIFIERS = [ "Environment :: Web Environment", "Framework :: Django", diff --git a/test_settings.py b/test_settings.py index a3facd1..9edd3d2 100644 --- a/test_settings.py +++ b/test_settings.py @@ -1,7 +1,6 @@ import os from distutils.util import strtobool - BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) ENABLE_VERSIONING = strtobool(os.environ.get("ENABLE_VERSIONING", "1")) EXTRA_INSTALLED_APPS = [] diff --git a/tests/base.py b/tests/base.py index 3bfe1aa..3a3061b 100644 --- a/tests/base.py +++ b/tests/base.py @@ -1,8 +1,3 @@ -from django.contrib.auth import get_permission_codename -from django.contrib.auth.models import Permission -from django.http import QueryDict -from django.test.client import RequestFactory - from cms.api import add_plugin, create_page, create_page_content from cms.middleware.toolbar import ToolbarMiddleware from cms.test_utils.testcases import CMSTestCase @@ -13,6 +8,10 @@ ) from cms.utils.conf import get_cms_setting from cms.utils.urlutils import admin_reverse +from django.contrib.auth import get_permission_codename +from django.contrib.auth.models import Permission +from django.http import QueryDict +from django.test.client import RequestFactory from djangocms_alias.constants import ( CATEGORY_LIST_URL_NAME, @@ -21,7 +20,8 @@ DETACH_ALIAS_PLUGIN_URL_NAME, LIST_ALIAS_URL_NAME, ) -from djangocms_alias.models import Alias as AliasModel, AliasContent, Category +from djangocms_alias.models import Alias as AliasModel +from djangocms_alias.models import AliasContent, Category from djangocms_alias.utils import is_versioning_enabled diff --git a/tests/requirements/compile.py b/tests/requirements/compile.py index e334076..7fd78bc 100755 --- a/tests/requirements/compile.py +++ b/tests/requirements/compile.py @@ -6,7 +6,6 @@ import sys from pathlib import Path - COMPILE_SETTINGS = { "py39-dj32-cms41": [], "py310-dj32-cms41": [], diff --git a/tests/test_admin.py b/tests/test_admin.py index b270828..fc9bf57 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -1,26 +1,26 @@ from unittest import skipUnless +from bs4 import BeautifulSoup +from cms.api import add_plugin +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.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, ) from djangocms_alias.models import ( Alias, - Alias as AliasModel, AliasContent, Category, ) +from djangocms_alias.models import ( + Alias as AliasModel, +) from djangocms_alias.utils import is_versioning_enabled from tests.base import BaseAliasPluginTestCase diff --git a/tests/test_admin_filters.py b/tests/test_admin_filters.py index fb9deaf..54e905b 100644 --- a/tests/test_admin_filters.py +++ b/tests/test_admin_filters.py @@ -1,16 +1,16 @@ from unittest import skipUnless +from cms.utils import get_current_site from django.contrib import admin from django.contrib.sites.models import Site -from cms.utils import get_current_site - from djangocms_alias.constants import ( SITE_FILTER_NO_SITE_VALUE, SITE_FILTER_URL_PARAM, ) from djangocms_alias.filters import CategoryFilter -from djangocms_alias.models import Alias as AliasModel, AliasContent, Category +from djangocms_alias.models import Alias as AliasModel +from djangocms_alias.models import AliasContent, Category from djangocms_alias.utils import is_versioning_enabled from .base import BaseAliasPluginTestCase diff --git a/tests/test_models.py b/tests/test_models.py index 739d815..3283af2 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -1,20 +1,19 @@ from distutils.version import LooseVersion +from cms.api import add_plugin, create_title +from cms.models import Placeholder from django import get_version from django.contrib.sites.models import Site from django.core.exceptions import ValidationError from django.urls import reverse -from cms.api import add_plugin, create_title -from cms.models import Placeholder - from djangocms_alias.cms_plugins import Alias -from djangocms_alias.models import Alias as AliasModel, AliasContent, Category +from djangocms_alias.models import Alias as AliasModel +from djangocms_alias.models import AliasContent, Category from djangocms_alias.utils import is_versioning_enabled from .base import BaseAliasPluginTestCase - DJANGO_VERSION = get_version() DJANGO_4_0 = LooseVersion(DJANGO_VERSION) < LooseVersion("4.1") diff --git a/tests/test_permissions.py b/tests/test_permissions.py index 423989e..14cf90e 100644 --- a/tests/test_permissions.py +++ b/tests/test_permissions.py @@ -1,8 +1,7 @@ +from cms.api import add_plugin from django.contrib.auth.models import Permission from django.contrib.contenttypes.models import ContentType -from cms.api import add_plugin - from djangocms_alias.cms_plugins import Alias from djangocms_alias.models import Alias as AliasModel from djangocms_alias.utils import is_versioning_enabled diff --git a/tests/test_templatetags.py b/tests/test_templatetags.py index 9876257..f1baf94 100644 --- a/tests/test_templatetags.py +++ b/tests/test_templatetags.py @@ -1,14 +1,14 @@ from unittest import skipUnless -from django.contrib.sites.models import Site -from django.test.utils import override_settings - from cms.api import add_plugin, create_page, create_page_content from cms.toolbar.utils import get_object_edit_url, get_object_preview_url +from django.contrib.sites.models import Site +from django.test.utils import override_settings from djangocms_alias.cms_plugins import Alias from djangocms_alias.constants import DEFAULT_STATIC_ALIAS_CATEGORY_NAME -from djangocms_alias.models import Alias as AliasModel, Category +from djangocms_alias.models import Alias as AliasModel +from djangocms_alias.models import Category from djangocms_alias.utils import is_versioning_enabled from .base import BaseAliasPluginTestCase diff --git a/tests/test_toolbar.py b/tests/test_toolbar.py index b0b1fdb..6f633df 100644 --- a/tests/test_toolbar.py +++ b/tests/test_toolbar.py @@ -2,9 +2,6 @@ from collections import ChainMap from unittest import skipUnless -from django.contrib.auth.models import Permission -from django.urls import reverse - from cms.cms_toolbars import ( ADMIN_MENU_IDENTIFIER, ADMINISTRATION_BREAK, @@ -14,6 +11,8 @@ from cms.toolbar.utils import get_object_edit_url from cms.utils.i18n import force_language from cms.utils.urlutils import admin_reverse +from django.contrib.auth.models import Permission +from django.urls import reverse from djangocms_alias.cms_toolbars import ALIAS_MENU_IDENTIFIER from djangocms_alias.constants import USAGE_ALIAS_URL_NAME diff --git a/tests/test_views.py b/tests/test_views.py index 955c717..18261c9 100644 --- a/tests/test_views.py +++ b/tests/test_views.py @@ -1,17 +1,16 @@ import re from unittest import skip, skipIf, skipUnless -from django.contrib.auth.models import Permission -from django.contrib.contenttypes.models import ContentType -from django.contrib.sites.models import Site -from django.test.utils import override_settings - from cms.api import add_plugin from cms.models import Placeholder from cms.utils import get_current_site from cms.utils.i18n import force_language from cms.utils.plugins import downcast_plugins from cms.utils.urlutils import add_url_parameters, admin_reverse +from django.contrib.auth.models import Permission +from django.contrib.contenttypes.models import ContentType +from django.contrib.sites.models import Site +from django.test.utils import override_settings from djangocms_alias.constants import ( CATEGORY_SELECT2_URL_NAME, diff --git a/tests/test_wizards.py b/tests/test_wizards.py index 4280348..a74e901 100644 --- a/tests/test_wizards.py +++ b/tests/test_wizards.py @@ -1,9 +1,8 @@ -from django.contrib.sites.models import Site -from django.utils import translation - from cms.utils import get_current_site from cms.wizards.forms import WizardStep2BaseForm, step2_form_factory from cms.wizards.helpers import get_entries as get_wizard_entires +from django.contrib.sites.models import Site +from django.utils import translation from djangocms_alias.models import Category from djangocms_alias.utils import is_versioning_enabled