diff --git a/djangocms_link/admin.py b/djangocms_link/admin.py index 3c4bc288..07b83dba 100644 --- a/djangocms_link/admin.py +++ b/djangocms_link/admin.py @@ -1,16 +1,17 @@ -from cms.models import Page, PageContent -from cms.utils import get_language_from_request from django.apps import apps from django.contrib import admin -from django.core.exceptions import PermissionDenied, FieldError -from django.http import JsonResponse, Http404 +from django.core.exceptions import FieldError, PermissionDenied +from django.http import JsonResponse from django.urls import path from django.views.generic.list import BaseListView from cms import __version__ +from cms.models import Page, PageContent +from cms.utils import get_language_from_request from . import models + _version = int(__version__.split(".")[0]) @@ -96,15 +97,14 @@ def get_queryset(self): ) else: # django CMS 3 - qs = list( - PageContent.objects.filter(language=self.language, title__icontains=self.term).order_by("page__node__path") - ) + qs = list(PageContent.objects.filter( + language=self.language, title__icontains=self.term + ).order_by("page__node__path")) for page_content in qs: # Patch the missing get_absolute_url method page_content.get_absolute_url = lambda: page_content.page.get_absolute_url() return qs - def process_request(self, request): """ Validate request integrity, extract and return request parameters. diff --git a/djangocms_link/apps.py b/djangocms_link/apps.py index 1a1da5c0..68722e7d 100644 --- a/djangocms_link/apps.py +++ b/djangocms_link/apps.py @@ -1,6 +1,7 @@ from django.apps import AppConfig from django.utils.translation import gettext_lazy as _ + class DjangoCmsLinkConfig(AppConfig): name = "djangocms_link" verbose_name = _("django CMS Link") diff --git a/djangocms_link/fields.py b/djangocms_link/fields.py index b399182b..b531b9e5 100644 --- a/djangocms_link/fields.py +++ b/djangocms_link/fields.py @@ -11,6 +11,7 @@ from cms.utils.urlutils import admin_reverse + try: from filer.fields.file import AdminFileWidget, FilerFileField from filer.models import File @@ -239,7 +240,7 @@ def run_validators(self, value): self.validators = getattr(self, f"{link_type}_validators", []) super().run_validators(value[link_type]) if "anchor" in value: - self.validators = getattr(self, f"anchor_validators", []) + self.validators = getattr(self, "anchor_validators", []) super().run_validators(value["anchor"]) def _get_pos(self, link_type): @@ -247,7 +248,6 @@ def _get_pos(self, link_type): return self.widget.data_pos.get(link_type) - class LinkField(JSONField): """A link is a JSON field with a default LinkFormField""" diff --git a/djangocms_link/forms.py b/djangocms_link/forms.py index 470af553..12acf949 100644 --- a/djangocms_link/forms.py +++ b/djangocms_link/forms.py @@ -4,6 +4,7 @@ from cms.forms.fields import PageSelectFormField as PageSearchField from djangocms_attributes_field.widgets import AttributesWidget + from djangocms_link.helpers import get_queryset_manager from .models import Link diff --git a/djangocms_link/migrations/0017_link_link.py b/djangocms_link/migrations/0017_link_link.py index 83388792..7e16e32e 100644 --- a/djangocms_link/migrations/0017_link_link.py +++ b/djangocms_link/migrations/0017_link_link.py @@ -1,6 +1,7 @@ # Generated by Django 4.2.16 on 2024-10-24 19:46 from django.db import migrations + import djangocms_link.fields @@ -39,7 +40,7 @@ def backward(apps, schema_editor): class Migration(migrations.Migration): dependencies = [ - ("djangocms_link", "0001_squashed_0016_alter_link_cmsplugin_ptr"), + ("djangocms_link", "0016_alter_link_cmsplugin_ptr"), ] operations = [ diff --git a/djangocms_link/models.py b/djangocms_link/models.py index 4bd7b992..a5452dc8 100644 --- a/djangocms_link/models.py +++ b/djangocms_link/models.py @@ -2,8 +2,6 @@ Enables the user to add a "Link" plugin that displays a link using the HTML tag. """ -from tabnanny import verbose - from django.conf import settings from django.contrib.sites.models import Site from django.core.exceptions import ValidationError @@ -12,10 +10,9 @@ from django.utils.translation import gettext from django.utils.translation import gettext_lazy as _ -from cms.models import CMSPlugin, Page +from cms.models import CMSPlugin from djangocms_attributes_field.fields import AttributesField -from filer.fields.file import FilerFileField from .fields import LinkField from .helpers import get_link @@ -221,7 +218,7 @@ def clean(self): code='required', ) -class Link(AbstractLink): +class Link(AbstractLink): class Meta: abstract = False diff --git a/djangocms_link/validators.py b/djangocms_link/validators.py index dbb66e99..7f182a7c 100644 --- a/djangocms_link/validators.py +++ b/djangocms_link/validators.py @@ -86,4 +86,3 @@ def __call__(self, value): if scheme == "mailto": return EmailValidator()(value[7:]) return super().__call__(value) -