diff --git a/djangocms_alias/admin.py b/djangocms_alias/admin.py index d605187..0f32954 100644 --- a/djangocms_alias/admin.py +++ b/djangocms_alias/admin.py @@ -91,9 +91,7 @@ def get_actions_list(self) -> list: """Add alias usage list actions""" return super().get_actions_list() + [self._get_alias_usage_link] - def can_change_content( - self, request: HttpRequest, content_obj: AliasContent - ) -> bool: + def can_change_content(self, request: HttpRequest, content_obj: AliasContent) -> bool: """Returns True if user can change content_obj""" if content_obj and is_versioning_enabled(): version = Version.objects.get_for_content(content_obj) @@ -111,9 +109,7 @@ def has_delete_permission(self, request: HttpRequest, obj: Alias = None) -> bool return request.user.is_superuser return False - def save_model( - self, request: HttpRequest, obj: Alias, form: forms.Form, change: bool - ) -> None: + def save_model(self, request: HttpRequest, obj: Alias, form: forms.Form, change: bool) -> None: super().save_model(request, obj, form, change) # Only emit content changes if Versioning is not installed because @@ -147,9 +143,7 @@ def delete_model(self, request: HttpRequest, obj: Alias): sender=self.model, ) - def _get_alias_usage_link( - self, obj: Alias, request: HttpRequest, disabled: bool = False - ) -> str: + def _get_alias_usage_link(self, obj: Alias, request: HttpRequest, disabled: bool = False) -> str: url = admin_reverse(USAGE_ALIAS_URL_NAME, args=[obj.pk]) return self.admin_action_button(url, "info", _("View usage"), disabled=disabled) @@ -169,9 +163,7 @@ class AliasContentAdmin(admin.ModelAdmin): actions = None change_form_template = "admin/djangocms_alias/aliascontent/change_form.html" - def changelist_view( - self, request: HttpRequest, extra_context: dict = None - ) -> HttpResponse: + def changelist_view(self, request: HttpRequest, extra_context: dict = None) -> HttpResponse: """Needed for the Alias Content Admin breadcrumbs""" return HttpResponseRedirect( admin_reverse( @@ -191,8 +183,7 @@ def change_view( if not obj: raise Http404() return HttpResponseRedirect( - admin_reverse(CHANGE_ALIAS_URL_NAME, args=(obj.alias_id,)) - + f"?language={obj.language}" + admin_reverse(CHANGE_ALIAS_URL_NAME, args=(obj.alias_id,)) + f"?language={obj.language}" ) def has_module_permission(self, request: HttpRequest) -> bool: diff --git a/djangocms_alias/cms_config.py b/djangocms_alias/cms_config.py index 573057d..027278d 100644 --- a/djangocms_alias/cms_config.py +++ b/djangocms_alias/cms_config.py @@ -19,12 +19,9 @@ class AliasCMSConfig(CMSAppConfig): cms_toolbar_enabled_models = [(AliasContent, render_alias_content)] moderated_models = [AliasContent] - djangocms_moderation_enabled = getattr( - settings, "MODERATING_ALIAS_MODELS_ENABLED", True - ) + djangocms_moderation_enabled = getattr(settings, "MODERATING_ALIAS_MODELS_ENABLED", True) djangocms_versioning_enabled = ( - getattr(settings, "VERSIONING_ALIAS_MODELS_ENABLED", True) - and djangocms_versioning_installed + getattr(settings, "VERSIONING_ALIAS_MODELS_ENABLED", True) and djangocms_versioning_installed ) if djangocms_versioning_enabled: @@ -42,9 +39,7 @@ class AliasCMSConfig(CMSAppConfig): ), ] - djangocms_references_enabled = getattr( - settings, "REFERENCES_ALIAS_MODELS_ENABLED", True - ) + djangocms_references_enabled = getattr(settings, "REFERENCES_ALIAS_MODELS_ENABLED", True) reference_fields = [ (AliasPlugin, "alias"), ] diff --git a/djangocms_alias/cms_menus.py b/djangocms_alias/cms_menus.py index bfad7a6..cb9bc32 100644 --- a/djangocms_alias/cms_menus.py +++ b/djangocms_alias/cms_menus.py @@ -9,9 +9,7 @@ class AliasDisableMenu(Modifier): """Disable menu rendering on alias pages""" def modify(self, request, nodes, namespace, root_id, post_cut, breadcrumb): - if request.toolbar.app_name == PLUGIN_URL_NAME_PREFIX or isinstance( - request.toolbar.obj, AliasContent - ): + if request.toolbar.app_name == PLUGIN_URL_NAME_PREFIX or isinstance(request.toolbar.obj, AliasContent): return [] return nodes diff --git a/djangocms_alias/cms_plugins.py b/djangocms_alias/cms_plugins.py index 6214209..f440106 100644 --- a/djangocms_alias/cms_plugins.py +++ b/djangocms_alias/cms_plugins.py @@ -32,10 +32,7 @@ class Alias(CMSPluginBase): form = AliasPluginForm def get_render_template(self, context, instance, placeholder): - if ( - isinstance(instance.placeholder.source, AliasContent) - and instance.is_recursive() - ): + if isinstance(instance.placeholder.source, AliasContent) and instance.is_recursive(): return "djangocms_alias/alias_recursive.html" return f"djangocms_alias/{instance.template}/alias.html" @@ -115,9 +112,7 @@ def can_create_alias(cls, user, plugins=None, replace=False): return True elif replace: target_placeholder = plugins[0].placeholder - if not target_placeholder.check_source(user) or not has_plugin_permission( - user, Alias.__name__, "add" - ): + if not target_placeholder.check_source(user) or not has_plugin_permission(user, Alias.__name__, "add"): return False return all( @@ -142,9 +137,7 @@ def can_detach(cls, user, target_placeholder, plugins): @classmethod def detach_alias_plugin(cls, plugin, language): - source_placeholder = plugin.alias.get_placeholder( - language, show_draft_content=True - ) # We're in edit mode + source_placeholder = plugin.alias.get_placeholder(language, show_draft_content=True) # We're in edit mode target_placeholder = plugin.placeholder # Deleting uses a copy of a plugin to preserve pk on existing diff --git a/djangocms_alias/cms_toolbars.py b/djangocms_alias/cms_toolbars.py index 4c42b6f..87f102c 100644 --- a/djangocms_alias/cms_toolbars.py +++ b/djangocms_alias/cms_toolbars.py @@ -71,11 +71,7 @@ def add_aliases_link_to_admin_menu(self): url = admin_reverse(LIST_ALIAS_URL_NAME) obj = self.toolbar.get_object() - language = ( - obj.language - if hasattr(obj, "language") - else get_language_from_request(self.request) - ) + language = obj.language if hasattr(obj, "language") else get_language_from_request(self.request) if language is None: language = get_default_language() url += f'?{urlencode({"language": language})}' @@ -152,9 +148,7 @@ def get_insert_position(cls, admin_menu, item_name): return end.index def enable_create_wizard_button(self): - button_lists = [ - result.item for result in self.toolbar.find_items(item_type=ButtonList) - ] + button_lists = [result.item for result in self.toolbar.find_items(item_type=ButtonList)] buttons = list( # flatten the list itertools.chain.from_iterable([item.buttons for item in button_lists]) @@ -162,9 +156,7 @@ def enable_create_wizard_button(self): # There will always be this button, because we are in the context of # alias app views - create_wizard_button = [ - button for button in buttons if button.name == gettext("Create") - ][0] + create_wizard_button = [button for button in buttons if button.name == gettext("Create")][0] from cms.wizards.wizard_pool import entry_choices @@ -195,9 +187,7 @@ def override_language_switcher(self): if alias_content: with force_language(code): url = alias_content.get_absolute_url() - 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): @@ -217,17 +207,13 @@ def change_language_menu(self): current_placeholder = alias_content.placeholder remove = [ - (code, languages.get(code, code)) - for code in alias_content.alias.get_languages() - if code in languages + (code, languages.get(code, code)) for code in alias_content.alias.get_languages() if code in languages ] add = [code for code in languages.items() if code not in remove] copy = [ (code, name) for code, name in languages.items() - if code != self.current_lang - and (code, name) in remove - and current_placeholder + if code != self.current_lang and (code, name) in remove and current_placeholder ] if add or remove or copy: @@ -241,9 +227,7 @@ def change_language_menu(self): add_url = admin_reverse("djangocms_alias_aliascontent_add") for code, name in add: - url = add_url_parameters( - add_url, language=code, alias=alias_content.alias_id - ) + url = add_url_parameters(add_url, language=code, alias=alias_content.alias_id) add_plugins_menu.add_modal_item(name, url=url) if remove: diff --git a/djangocms_alias/filters.py b/djangocms_alias/filters.py index eab9bfc..e16e925 100644 --- a/djangocms_alias/filters.py +++ b/djangocms_alias/filters.py @@ -38,17 +38,13 @@ def choices(self, changelist): } yield { "selected": self.value() == SITE_FILTER_NO_SITE_VALUE, - "query_string": changelist.get_query_string( - {self.parameter_name: SITE_FILTER_NO_SITE_VALUE} - ), + "query_string": changelist.get_query_string({self.parameter_name: SITE_FILTER_NO_SITE_VALUE}), "display": _("No site"), } for lookup, title in self.lookup_choices: yield { "selected": self.value() == str(lookup), - "query_string": changelist.get_query_string( - {self.parameter_name: lookup} - ), + "query_string": changelist.get_query_string({self.parameter_name: lookup}), "display": title, } @@ -62,11 +58,7 @@ def lookups(self, request, model_admin): qs = model_admin.get_queryset(request) cat_id = qs.values_list("category", flat=True) # Ensure the category is ordered by the name alphabetically by default - cat = ( - Category.objects.filter(pk__in=cat_id) - .translated(get_language()) - .order_by("translations__name") - ) + cat = Category.objects.filter(pk__in=cat_id).translated(get_language()).order_by("translations__name") for obj in cat: yield str(obj.pk), smart_str(obj) @@ -83,8 +75,6 @@ def choices(self, changelist): for lookup, title in self.lookup_choices: yield { "selected": self.value() == str(lookup), - "query_string": changelist.get_query_string( - {self.parameter_name: lookup} - ), + "query_string": changelist.get_query_string({self.parameter_name: lookup}), "display": title, } diff --git a/djangocms_alias/forms.py b/djangocms_alias/forms.py index d8e1ae4..afc1f88 100644 --- a/djangocms_alias/forms.py +++ b/djangocms_alias/forms.py @@ -75,9 +75,7 @@ def clean(self): placeholder = cleaned_data.get("placeholder") if not plugin and not placeholder: - raise forms.ValidationError( - _("A plugin or placeholder is required to create an alias.") - ) + raise forms.ValidationError(_("A plugin or placeholder is required to create an alias.")) if plugin and placeholder: raise forms.ValidationError( @@ -125,9 +123,7 @@ def clean(self): language=cleaned_data.get("language"), alias__category=cleaned_data.get("category"), ).exists(): - raise forms.ValidationError( - _("Alias with this Name and Category already exists.") - ) + raise forms.ValidationError(_("Alias with this Name and Category already exists.")) return cleaned_data @@ -177,9 +173,7 @@ def save(self): class CreateAliasWizardForm(forms.Form): - name = forms.CharField( - label=_("Name"), required=True, widget=AdminTextInputWidget() - ) + name = forms.CharField(label=_("Name"), required=True, widget=AdminTextInputWidget()) site = forms.ModelChoiceField( queryset=Site.objects.all(), required=False, @@ -276,9 +270,7 @@ class AliasPluginForm(forms.ModelForm): queryset=Category.objects.all(), widget=CategorySelectWidget( attrs={ - "data-placeholder": _( - "Select category to restrict the list of aliases below" - ), # noqa: E501 + "data-placeholder": _("Select category to restrict the list of aliases below"), # noqa: E501 }, ), empty_label="", @@ -334,8 +326,6 @@ def clean(self): language=cleaned_data.get("language"), alias__category=cleaned_data.get("category"), ).exists(): - raise forms.ValidationError( - _("Alias with this Name and Category already exists.") - ) + raise forms.ValidationError(_("Alias with this Name and Category already exists.")) return cleaned_data diff --git a/djangocms_alias/migrations/0001_initial.py b/djangocms_alias/migrations/0001_initial.py index 6111d96..1867163 100644 --- a/djangocms_alias/migrations/0001_initial.py +++ b/djangocms_alias/migrations/0001_initial.py @@ -148,9 +148,7 @@ class Migration(migrations.Migration): ), ( "language_code", - models.CharField( - db_index=True, max_length=15, verbose_name="Language" - ), + models.CharField(db_index=True, max_length=15, verbose_name="Language"), ), ( "name", diff --git a/djangocms_alias/migrations/0004_alter_aliascontent_language.py b/djangocms_alias/migrations/0004_alter_aliascontent_language.py index 21b2f2f..a8ef3da 100644 --- a/djangocms_alias/migrations/0004_alter_aliascontent_language.py +++ b/djangocms_alias/migrations/0004_alter_aliascontent_language.py @@ -13,8 +13,6 @@ class Migration(migrations.Migration): migrations.AlterField( model_name="aliascontent", name="language", - field=models.CharField( - default=django.utils.translation.get_language, max_length=10 - ), + field=models.CharField(default=django.utils.translation.get_language, max_length=10), ), ] diff --git a/djangocms_alias/models.py b/djangocms_alias/models.py index 76c20f1..f919081 100644 --- a/djangocms_alias/models.py +++ b/djangocms_alias/models.py @@ -104,9 +104,7 @@ class Meta: verbose_name = _("alias") verbose_name_plural = _("aliases") ordering = ["position"] - unique_together = ( - ("static_code", "site"), - ) # Only restrict instances that have a site specified + unique_together = (("static_code", "site"),) # Only restrict instances that have a site specified def __init__(self, *args, **kwargs): self._plugins_cache = {} @@ -130,9 +128,7 @@ def is_in_use(self): def objects_using(self): objects = set() object_ids = defaultdict(set) - plugins = self.cms_plugins.select_related("placeholder").prefetch_related( - "placeholder__source" - ) + plugins = self.cms_plugins.select_related("placeholder").prefetch_related("placeholder__source") for plugin in plugins: obj = plugin.placeholder.source obj_class_name = obj.__class__.__name__ @@ -147,11 +143,7 @@ def objects_using(self): else: objects.update([obj]) objects.update( - [ - obj - for model_class, ids in object_ids.items() - for obj in model_class.objects.filter(pk__in=ids) - ] + [obj for model_class, ids in object_ids.items() for obj in model_class.objects.filter(pk__in=ids)] ) return list(objects) @@ -202,9 +194,7 @@ def get_content(self, language=None, show_draft_content=False): return self._content_cache[language] def get_placeholder(self, language=None, show_draft_content=False): - content = self.get_content( - language=language, show_draft_content=show_draft_content - ) + content = self.get_content(language=language, show_draft_content=show_draft_content) return getattr(content, "placeholder", None) def get_plugins(self, language=None): @@ -427,7 +417,5 @@ def is_recursive(self, language=None): plugins = AliasPlugin.objects.filter( placeholder_id=placeholder, ) - plugins = plugins.filter( - Q(pk=self) | Q(alias__contents__placeholders=placeholder) - ) + plugins = plugins.filter(Q(pk=self) | Q(alias__contents__placeholders=placeholder)) return plugins.exists() diff --git a/djangocms_alias/templatetags/djangocms_alias_tags.py b/djangocms_alias/templatetags/djangocms_alias_tags.py index b6f5c98..d0f04d6 100644 --- a/djangocms_alias/templatetags/djangocms_alias_tags.py +++ b/djangocms_alias/templatetags/djangocms_alias_tags.py @@ -107,13 +107,9 @@ def _get_alias(self, request, static_code, extra_bits): return None # Parler's get_or_create doesn't work well with translations, so we must perform our own get or create - default_category = Category.objects.filter( - translations__name=DEFAULT_STATIC_ALIAS_CATEGORY_NAME - ).first() + default_category = Category.objects.filter(translations__name=DEFAULT_STATIC_ALIAS_CATEGORY_NAME).first() if not default_category: - default_category = Category.objects.create( - name=DEFAULT_STATIC_ALIAS_CATEGORY_NAME - ) + default_category = Category.objects.create(name=DEFAULT_STATIC_ALIAS_CATEGORY_NAME) alias_creation_kwargs = { "static_code": static_code, @@ -123,13 +119,9 @@ def _get_alias(self, request, static_code, extra_bits): if "site" in extra_bits: alias_creation_kwargs["site"] = current_site - alias = Alias.objects.create( - category=default_category, **alias_creation_kwargs - ) + alias = Alias.objects.create(category=default_category, **alias_creation_kwargs) - if not AliasContent._base_manager.filter( - alias=alias, language=language - ).exists(): + if not AliasContent._base_manager.filter(alias=alias, language=language).exists(): # Create a first content object if none exists in the given language. # If versioning is enabled we can only create the records with a logged-in user / staff member if is_versioning_enabled() and not request.user.is_authenticated: @@ -174,9 +166,7 @@ def render_tag(self, context, static_code, extra_bits, nodelist=None): get_draft_content = True language = get_language_from_request(request) - placeholder = alias.get_placeholder( - language=language, show_draft_content=get_draft_content - ) + placeholder = alias.get_placeholder(language=language, show_draft_content=get_draft_content) if placeholder: content = renderer.render_placeholder( diff --git a/djangocms_alias/views.py b/djangocms_alias/views.py index 805cc47..068ac76 100644 --- a/djangocms_alias/views.py +++ b/djangocms_alias/views.py @@ -145,9 +145,7 @@ def create_alias_view(request): return HttpResponse(JAVASCRIPT_SUCCESS_RESPONSE) -def render_replace_response( - request, new_plugins, source_placeholder=None, source_plugin=None -): +def render_replace_response(request, new_plugins, source_placeholder=None, source_plugin=None): move_plugins, add_plugins = [], [] for plugin in new_plugins: root = plugin.parent.get_bound_plugin() if plugin.parent else plugin diff --git a/pyproject.toml b/pyproject.toml index a10167b..63c8c96 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,3 +1,6 @@ +[tool.ruff] +line-length = 119 + [tool.ruff.lint] select=[ "E", # pycodestyle errors @@ -10,14 +13,15 @@ select=[ "PLR", # pylint refactor "PLW", # pylint warning "UP", # pyupgrade + ] extend-ignore = [ - "PLR0915", - "C901", - "PLR0913", - "PLW1510", - "I001" , - "PLR0912" , - "E501" + "C901", # Too complex + "PLR0911", # Too many return statements + "PLR0912", # Too many branches + "PLR0913", # Too many arguments to function call + "PLR0915", # Too many statements + # TODO + "PLW1510" # subprocess.run without explicit argument ] diff --git a/tests/base.py b/tests/base.py index 3a3061b..dfd53dc 100644 --- a/tests/base.py +++ b/tests/base.py @@ -63,9 +63,7 @@ def setUp(self): self.category = Category.objects.create(name="test category") def _get_draft_page_placeholder(self): - page_content = create_page_content( - self.language, "Draft Page", self.page, created_by=self.superuser - ) + page_content = create_page_content(self.language, "Draft Page", self.page, created_by=self.superuser) return page_content.get_placeholders().get(slot="content") def _create_alias( @@ -100,9 +98,7 @@ def _create_alias( if is_versioning_enabled(): from djangocms_versioning.models import Version - version = Version.objects.create( - content=alias_content, created_by=self.superuser - ) + version = Version.objects.create(content=alias_content, created_by=self.superuser) if published: version.publish(self.superuser) @@ -115,14 +111,9 @@ def _get_version(self, grouper, version_state, language=None): from djangocms_versioning.models import Version - versions = Version.objects.filter_by_grouper(grouper).filter( - state=version_state - ) + versions = Version.objects.filter_by_grouper(grouper).filter(state=version_state) for version in versions: - if ( - hasattr(version.content, "language") - and version.content.language == language - ): + if hasattr(version.content, "language") and version.content.language == language: return version def _publish(self, grouper, language=None): @@ -161,9 +152,7 @@ def _create_page(self, title, language=None, site=None, published=True, **kwargs def get_alias_request(self, alias, lang_code="en", *args, **kwargs): request = self._get_instance_request(alias, *args, **kwargs) request.current_page = None - request = self._process_request_by_toolbar_middleware( - request, obj=alias.get_content(lang_code) - ) + request = self._process_request_by_toolbar_middleware(request, obj=alias.get_content(lang_code)) return request def get_page_request(self, page, obj=None, *args, **kwargs): @@ -239,23 +228,11 @@ def add_alias_plugin_to_page(self, page, alias, language=None): def get_staff_user_with_alias_permissions(self): staff_user = self._create_user("alias staff", is_staff=True, is_superuser=False) # noqa: E501 - self.add_permission( - staff_user, get_permission_codename("add", AliasModel._meta) - ) # noqa: E501 - self.add_permission( - staff_user, get_permission_codename("change", AliasModel._meta) - ) # noqa: E501 - self.add_permission( - staff_user, get_permission_codename("delete", AliasModel._meta) - ) # noqa: E501 - self.add_permission( - staff_user, get_permission_codename("add", AliasContent._meta) - ) # noqa: E501 - self.add_permission( - staff_user, get_permission_codename("change", AliasContent._meta) - ) # noqa: E501 - self.add_permission( - staff_user, get_permission_codename("delete", AliasContent._meta) - ) # noqa: E501 + self.add_permission(staff_user, get_permission_codename("add", AliasModel._meta)) # noqa: E501 + self.add_permission(staff_user, get_permission_codename("change", AliasModel._meta)) # noqa: E501 + self.add_permission(staff_user, get_permission_codename("delete", AliasModel._meta)) # noqa: E501 + self.add_permission(staff_user, get_permission_codename("add", AliasContent._meta)) # noqa: E501 + self.add_permission(staff_user, get_permission_codename("change", AliasContent._meta)) # noqa: E501 + self.add_permission(staff_user, get_permission_codename("delete", AliasContent._meta)) # noqa: E501 self.add_permission(staff_user, get_permission_codename("add", Category._meta)) # noqa: E501 return staff_user diff --git a/tests/test_admin.py b/tests/test_admin.py index fc9bf57..d1a16ca 100644 --- a/tests/test_admin.py +++ b/tests/test_admin.py @@ -66,14 +66,9 @@ def test_alias_content_manager_rendering_without_versioning_actions(self): response_content_decoded, ) - usage_url = admin_reverse( - USAGE_ALIAS_URL_NAME, args=[expected_en_content.alias.pk] - ) + usage_url = admin_reverse(USAGE_ALIAS_URL_NAME, args=[expected_en_content.alias.pk]) change_category_and_site_url = admin_reverse( - "{}_{}_change".format( - expected_en_content._meta.app_label, - expected_en_content.alias._meta.model_name, - ), + f"{expected_en_content._meta.app_label}_{expected_en_content.alias._meta.model_name}_change", args=(expected_en_content.alias.pk,), ) @@ -87,10 +82,7 @@ def test_alias_content_manager_rendering_without_versioning_actions(self): ) # check for add content admin link add_alias_link = admin_reverse( - "{}_{}_add".format( - expected_en_content._meta.app_label, - expected_en_content._meta.model_name, - ) + f"{expected_en_content._meta.app_label}_{expected_en_content._meta.model_name}_add" ) self.assertNotIn( # It is not currently possible to add an alias from the django admin changelist issue #97 @@ -174,14 +166,9 @@ def test_alias_changelist_rendering_with_versioning_actions(self): response_content_decoded, ) - usage_url = admin_reverse( - USAGE_ALIAS_URL_NAME, args=[expected_en_content.alias.pk] - ) + usage_url = admin_reverse(USAGE_ALIAS_URL_NAME, args=[expected_en_content.alias.pk]) settings_url = admin_reverse( - "{}_{}_change".format( - expected_en_content._meta.app_label, - expected_en_content.alias._meta.model_name, - ), + f"{expected_en_content._meta.app_label}_{expected_en_content.alias._meta.model_name}_change", args=(expected_en_content.alias.pk,), ) @@ -230,10 +217,7 @@ def test_alias_content_manager_rendering_preview_add_url(self): ) # check for add content admin link add_aliascontent_url = admin_reverse( - "{}_{}_add".format( - expected_en_content._meta.app_label, - expected_en_content._meta.model_name, - ) + f"{expected_en_content._meta.app_label}_{expected_en_content._meta.model_name}_add" ) self.assertNotIn( add_aliascontent_url, @@ -245,9 +229,7 @@ def _create_alias_and_categories(self, category_name, alias_content_name=None): alias_content_name = category_name category = Category.objects.create(name=category_name) alias = AliasModel.objects.create(category=category, position=0) - alias_content = AliasContent.objects.create( - alias=alias, name=alias_content_name, language="en" - ) + alias_content = AliasContent.objects.create(alias=alias, name=alias_content_name, language="en") return category, alias, alias_content @skipUnless(is_versioning_enabled(), "Test only relevant for versioning") @@ -287,13 +269,9 @@ def test_category_field_ordering_versioned(self): from djangocms_versioning.models import Version Version.objects.create(content=first_alias_content, created_by=self.superuser) - Version.objects.create( - content=first_alias_content_lower, created_by=self.superuser - ) + Version.objects.create(content=first_alias_content_lower, created_by=self.superuser) Version.objects.create(content=middle_alias_content, created_by=self.superuser) - Version.objects.create( - content=last_alias_content_lower, created_by=self.superuser - ) + Version.objects.create(content=last_alias_content_lower, created_by=self.superuser) Version.objects.create(content=last_alias_content, created_by=self.superuser) with self.login_user_context(self.superuser): @@ -460,15 +438,9 @@ def test_aliascontent_list_view(self): alias1_content = alias1.get_content(language=self.language) alias2_content = alias2.get_content(language=self.language) alias3_content = alias3.get_content(language=self.language) - aliascontent1_url = admin_reverse( - CHANGE_ALIAS_URL_NAME, args=[alias1_content.pk] - ) - aliascontent2_url = admin_reverse( - CHANGE_ALIAS_URL_NAME, args=[alias2_content.pk] - ) - aliascontent3_url = admin_reverse( - CHANGE_ALIAS_URL_NAME, args=[alias3_content.pk] - ) + aliascontent1_url = admin_reverse(CHANGE_ALIAS_URL_NAME, args=[alias1_content.pk]) + aliascontent2_url = admin_reverse(CHANGE_ALIAS_URL_NAME, args=[alias2_content.pk]) + aliascontent3_url = admin_reverse(CHANGE_ALIAS_URL_NAME, args=[alias3_content.pk]) self.assertContains(response, aliascontent1_url) self.assertContains(response, aliascontent2_url) @@ -537,9 +509,7 @@ def test_changelist_staff_user_without_permission(self): def test_changelist_staff_user_with_permission(self): user = self.get_staff_user_with_std_permissions() user.user_permissions.add( - Permission.objects.get( - content_type__app_label="djangocms_alias", codename="change_category" - ) + Permission.objects.get(content_type__app_label="djangocms_alias", codename="change_category") ) with self.login_user_context(user): response = self.client.get(self.get_category_list_endpoint()) @@ -549,9 +519,7 @@ def test_changelist_edit_button(self): with self.login_user_context(self.superuser): response = self.client.get(self.get_category_list_endpoint()) - self.assertContains( - response, '' "Alias contents" + ) expected_content = '