Skip to content

Commit

Permalink
Fix LinkPluginMixin
Browse files Browse the repository at this point in the history
  • Loading branch information
fsbraun committed Nov 1, 2024
1 parent b818bcd commit 462d07a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 34 deletions.
29 changes: 1 addition & 28 deletions djangocms_frontend/contrib/image/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from django.conf import settings as django_settings
from django.db.models.fields.related import ManyToOneRel
from django.utils.translation import gettext_lazy as _
from entangled.forms import EntangledModelForm
from filer.fields.image import AdminImageFormField, FilerImageField
from filer.models import Image, ThumbnailOption

Expand Down Expand Up @@ -45,13 +44,6 @@ def get_templates():
PICTURE_ALIGNMENT = get_alignment()


LINK_TARGET = (
("_blank", _("Open in new window")),
("_self", _("Open in same window")),
("_parent", _("Delegate to parent")),
("_top", _("Delegate to top")),
)

RESPONSIVE_IMAGE_CHOICES = (
("inherit", _("Let settings.DJANGOCMS_PICTURE_RESPONSIVE_IMAGES decide")),
("yes", _("Yes")),
Expand All @@ -61,10 +53,9 @@ def get_templates():

class ImageForm(
TemplateChoiceMixin,
AbstractLinkForm,
ResponsiveFormMixin,
MarginFormMixin,
EntangledModelForm,
AbstractLinkForm,
):
"""
Content > "Image" Plugin
Expand Down Expand Up @@ -217,24 +208,6 @@ class Meta:
def clean(self):
super().clean()
data = self.cleaned_data
# there can be only one link type
if (
sum(
(
bool(data.get("external_link", False)),
bool(data.get("internal_link", False)),
bool(data.get("file_link", False)),
)
)
> 1
):
raise forms.ValidationError(
_(
"You have given more than one external, internal, or file link target. "
"Only one option is allowed."
)
)

# you shall only set one image kind
if not data.get("picture", False) and not data.get("external_picture", False):
raise forms.ValidationError(
Expand Down
7 changes: 1 addition & 6 deletions djangocms_frontend/contrib/link/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,7 @@ class LinkPluginMixin:
link_fields = (
(("site", "url_grouper"),)
if apps.is_installed("djangocms_url_manager")
else (
("external_link", "internal_link"),
("mailto", "phone"),
("anchor", "target"),
"file_link",
)
else ("link", "target")
)

def render(self, context, instance, placeholder):
Expand Down

0 comments on commit 462d07a

Please sign in to comment.